summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2023-04-29 14:59:40 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2023-05-03 23:11:35 -0400
commitc06898cb841c4eaf8dfb7f7225e302a4c289cd0a (patch)
tree1499c659d2fdd5369ffdb8e810899a6be12b7190
parent104dd2f9872d1d0be38b444daf0c77f847364ad5 (diff)
downloadlighttpd-git-c06898cb841c4eaf8dfb7f7225e302a4c289cd0a.tar.gz
[core] move some shared funcs to call from modules
(e.g. support for HTTP/2 module mod_h2)
-rw-r--r--src/http-header-glue.c40
-rw-r--r--src/response.c38
2 files changed, 40 insertions, 38 deletions
diff --git a/src/http-header-glue.c b/src/http-header-glue.c
index e2a19c5f..a6e8bd9e 100644
--- a/src/http-header-glue.c
+++ b/src/http-header-glue.c
@@ -13,6 +13,7 @@
#include "http_date.h"
#include "http_etag.h"
#include "http_header.h"
+#include "plugin_config.h" /* config_feature_bool */
#include "sock_addr.h"
#include "stat_cache.h"
@@ -140,6 +141,45 @@ int http_response_redirect_to_directory(request_st * const r, int status) {
return 0;
}
+
+__attribute_cold__
+void
+http_response_delay (connection * const con)
+{
+ if (config_feature_bool(con->srv, "auth.delay-invalid-creds", 1)){
+ /*(delay sending response)*/
+ con->is_writable = 0;
+ con->traffic_limit_reached = 1;
+ }
+}
+
+
+int
+http_response_omit_header (request_st * const r, const data_string * const ds)
+{
+ const size_t klen = buffer_clen(&ds->key);
+ if (klen == sizeof("X-Sendfile")-1
+ && buffer_eq_icase_ssn(ds->key.ptr, CONST_STR_LEN("X-Sendfile")))
+ return 1;
+ if (klen >= sizeof("X-LIGHTTPD-")-1
+ && buffer_eq_icase_ssn(ds->key.ptr, CONST_STR_LEN("X-LIGHTTPD-"))) {
+ if (klen == sizeof("X-LIGHTTPD-KBytes-per-second")-1
+ && buffer_eq_icase_ssn(ds->key.ptr+sizeof("X-LIGHTTPD-")-1,
+ CONST_STR_LEN("KBytes-per-second"))) {
+ /* "X-LIGHTTPD-KBytes-per-second" */
+ off_t limit = strtol(ds->value.ptr, NULL, 10) << 10; /*(*=1024)*/
+ if (limit > 0
+ && (limit < r->conf.bytes_per_second
+ || 0 == r->conf.bytes_per_second)) {
+ r->conf.bytes_per_second = limit;
+ }
+ }
+ return 1;
+ }
+ return 0;
+}
+
+
#define MTIME_CACHE_MAX 16
struct mtime_cache_type {
unix_time64_t mtime; /* key */
diff --git a/src/response.c b/src/response.c
index 1bebea4a..0b649ca8 100644
--- a/src/response.c
+++ b/src/response.c
@@ -27,44 +27,6 @@
__attribute_cold__
-void
-http_response_delay (connection * const con)
-{
- if (config_feature_bool(con->srv, "auth.delay-invalid-creds", 1)){
- /*(delay sending response)*/
- con->is_writable = 0;
- con->traffic_limit_reached = 1;
- }
-}
-
-
-int
-http_response_omit_header (request_st * const r, const data_string * const ds)
-{
- const size_t klen = buffer_clen(&ds->key);
- if (klen == sizeof("X-Sendfile")-1
- && buffer_eq_icase_ssn(ds->key.ptr, CONST_STR_LEN("X-Sendfile")))
- return 1;
- if (klen >= sizeof("X-LIGHTTPD-")-1
- && buffer_eq_icase_ssn(ds->key.ptr, CONST_STR_LEN("X-LIGHTTPD-"))) {
- if (klen == sizeof("X-LIGHTTPD-KBytes-per-second")-1
- && buffer_eq_icase_ssn(ds->key.ptr+sizeof("X-LIGHTTPD-")-1,
- CONST_STR_LEN("KBytes-per-second"))) {
- /* "X-LIGHTTPD-KBytes-per-second" */
- off_t limit = strtol(ds->value.ptr, NULL, 10) << 10; /*(*=1024)*/
- if (limit > 0
- && (limit < r->conf.bytes_per_second
- || 0 == r->conf.bytes_per_second)) {
- r->conf.bytes_per_second = limit;
- }
- }
- return 1;
- }
- return 0;
-}
-
-
-__attribute_cold__
static handler_t
http_response_physical_path_error (request_st * const r, const int code, const char * const msg)
{