diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2020-10-09 02:58:41 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2020-10-11 12:19:27 -0400 |
commit | 4d6d1e790a179c1deb3bc066f0700c9bf12aecb7 (patch) | |
tree | 20631c3b4f55d3bd1fa79b40662cd5d5f1cbff08 /src | |
parent | bd8edb51d0ac2c06c2eaaee7613eeaf35db63546 (diff) | |
download | lighttpd-git-4d6d1e790a179c1deb3bc066f0700c9bf12aecb7.tar.gz |
[multiple] use light_btst() for hdr existence chk
Diffstat (limited to 'src')
-rw-r--r-- | src/http-header-glue.c | 25 | ||||
-rw-r--r-- | src/mod_cgi.c | 2 | ||||
-rw-r--r-- | src/mod_deflate.c | 3 | ||||
-rw-r--r-- | src/mod_extforward.c | 2 | ||||
-rw-r--r-- | src/mod_webdav.c | 3 | ||||
-rw-r--r-- | src/response.c | 3 |
6 files changed, 15 insertions, 23 deletions
diff --git a/src/http-header-glue.c b/src/http-header-glue.c index b87330e8..a60fb222 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -186,10 +186,9 @@ int http_response_handle_cachable(request_st * const r, const buffer * const mti CONST_STR_LEN("If-None-Match")))) { /*(weak etag comparison must not be used for ranged requests)*/ int range_request = - (r->conf.range_requests - && (200 == r->http_status || 0 == r->http_status) - && NULL != http_header_request_get(r, HTTP_HEADER_RANGE, - CONST_STR_LEN("Range"))); + (light_btst(r->rqst_htags, HTTP_HEADER_RANGE) + && r->conf.range_requests + && (200 == r->http_status || 0 == r->http_status)); if (etag_is_equal(&r->physical.etag, vb->ptr, !range_request)) { if (http_method_get_or_head(r->http_method)) { r->http_status = 304; @@ -582,8 +581,7 @@ void http_response_send_file (request_st * const r, buffer * const path) { /* set response content-type, if not set already */ - if (NULL == http_header_response_get(r, HTTP_HEADER_CONTENT_TYPE, - CONST_STR_LEN("Content-Type"))) { + if (!light_btst(r->resp_htags, HTTP_HEADER_CONTENT_TYPE)) { const buffer *content_type = stat_cache_content_type_get(sce, r); if (buffer_string_is_empty(content_type)) { /* we are setting application/octet-stream, but also announce that @@ -611,15 +609,13 @@ void http_response_send_file (request_st * const r, buffer * const path) { } if (allow_caching) { - const buffer *etag = (0 != r->conf.etag_flags) - ? stat_cache_etag_get(sce, r->conf.etag_flags) - : NULL; - if (!buffer_string_is_empty(etag)) { - if (NULL == http_header_response_get(r, HTTP_HEADER_ETAG, - CONST_STR_LEN("ETag"))) { + if (!light_btst(r->resp_htags, HTTP_HEADER_ETAG) + && 0 != r->conf.etag_flags) { + const buffer *etag = + stat_cache_etag_get(sce, r->conf.etag_flags); + if (!buffer_string_is_empty(etag)) { /* generate e-tag */ etag_mutate(&r->physical.etag, etag); - http_header_response_set(r, HTTP_HEADER_ETAG, CONST_STR_LEN("ETag"), CONST_BUF_LEN(&r->physical.etag)); @@ -656,8 +652,7 @@ void http_response_send_file (request_st * const r, buffer * const path) { && (200 == r->http_status || 0 == r->http_status) && NULL != (vb = http_header_request_get(r, HTTP_HEADER_RANGE, CONST_STR_LEN("Range"))) - && NULL == http_header_response_get(r, HTTP_HEADER_CONTENT_ENCODING, - CONST_STR_LEN("Content-Encoding"))) { + && !light_btst(r->resp_htags, HTTP_HEADER_CONTENT_ENCODING)) { const buffer *range = vb; int do_range_request = 1; /* check if we have a conditional GET */ diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 7d15731d..d7d12bd5 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -906,7 +906,7 @@ URIHANDLER_FUNC(cgi_is_handled) { hctx->conf.upgrade = hctx->conf.upgrade && r->http_version == HTTP_VERSION_1_1 - && NULL != http_header_request_get(r, HTTP_HEADER_UPGRADE, CONST_STR_LEN("Upgrade")); + && light_btst(r->rqst_htags, HTTP_HEADER_UPGRADE); hctx->opts.fdfmt = S_IFIFO; hctx->opts.backend = BACKEND_CGI; hctx->opts.authorizer = 0; diff --git a/src/mod_deflate.c b/src/mod_deflate.c index fba6e133..ca7776d1 100644 --- a/src/mod_deflate.c +++ b/src/mod_deflate.c @@ -1532,8 +1532,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) { && r->write_queue.first->type == FILE_CHUNK && r->write_queue.first->file.start == 0 && !r->write_queue.first->file.is_temp - && !http_header_response_get(r, HTTP_HEADER_RANGE, - CONST_STR_LEN("Range"))) { + && !light_btst(r->resp_htags, HTTP_HEADER_RANGE)) { tb = mod_deflate_cache_file_name(r, p->conf.cache_dir, vb); /*(checked earlier and skipped if Transfer-Encoding had been set)*/ stat_cache_entry *sce = stat_cache_get_entry(tb); diff --git a/src/mod_extforward.c b/src/mod_extforward.c index b9cf3831..d1e4b6b0 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -1020,7 +1020,7 @@ static handler_t mod_extforward_Forwarded (request_st * const r, plugin_data * c #if 0 if ((p->conf.opts & PROXY_FORWARDED_CREATE_XFF) - && NULL == http_header_request_get(r, HTTP_HEADER_X_FORWARDED_FOR, CONST_STR_LEN("X-Forwarded-For"))) { + && !light_btst(r->rqst_htags, HTTP_HEADER_X_FORWARDED_FOR)) { /* create X-Forwarded-For if not present * (and at least original connecting IP is a trusted proxy) */ buffer *xff = r->tmp_buf; diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 33aadb69..9b97b2f1 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -4303,8 +4303,7 @@ mod_webdav_put_0 (request_st * const r, const plugin_config * const pconf) static handler_t mod_webdav_put_prep (request_st * const r, const plugin_config * const pconf) { - if (NULL != http_header_request_get(r, HTTP_HEADER_CONTENT_RANGE, - CONST_STR_LEN("Content-Range"))) { + if (light_btst(r->rqst_htags, HTTP_HEADER_CONTENT_RANGE)) { if (pconf->opts & MOD_WEBDAV_UNSAFE_PARTIAL_PUT_COMPAT) return HANDLER_GO_ON; /* [RFC7231] 4.3.4 PUT diff --git a/src/response.c b/src/response.c index fa56ee16..8ca87bd7 100644 --- a/src/response.c +++ b/src/response.c @@ -197,8 +197,7 @@ static handler_t http_response_physical_path_check(request_st * const r) { /* file name to be read was too long. return 404 */ case ENOENT: if (r->http_method == HTTP_METHOD_OPTIONS - && NULL != http_header_response_get(r, HTTP_HEADER_ALLOW, - CONST_STR_LEN("Allow"))) { + && light_btst(r->resp_htags, HTTP_HEADER_ALLOW)) { r->http_status = 200; return HANDLER_FINISHED; } |