From c06898cb841c4eaf8dfb7f7225e302a4c289cd0a Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 29 Apr 2023 14:59:40 -0400 Subject: [core] move some shared funcs to call from modules (e.g. support for HTTP/2 module mod_h2) --- src/http-header-glue.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/response.c | 38 -------------------------------------- 2 files changed, 40 insertions(+), 38 deletions(-) (limited to 'src') 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 @@ -26,44 +26,6 @@ #include -__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) -- cgit v1.2.1