diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2020-09-11 17:25:43 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2020-10-11 12:19:26 -0400 |
commit | 2e0676fd6dbab9da6b838f8f803bfc5dec11b346 (patch) | |
tree | c5a0e1841c9fc71691a82e64b7b6f3d68b5ae60a /src/mod_extforward.c | |
parent | 68ec5ad64226883182602d42eb9e2d4c100fed74 (diff) | |
download | lighttpd-git-2e0676fd6dbab9da6b838f8f803bfc5dec11b346.tar.gz |
[core] extend (data_string *) to store header id
(optional addition to (data_string *), used by http_header.[ch])
extend (data_string *) instead of creating another data_* TYPE_*
(new data type would probably have (data_string *) as base class)
(might revisit choice in the future)
HTTP_HEADER_UNSPECIFIED has been removed. It was used in select
locations as an optimization to avoid looking up enum header_header_e
before checking the array, but the ordering in the array now relies
on having the id. Having the id allows for a quick check if a common
header is present or not in the htags bitmask, before checking the
array, and allows for integer comparison in the log(n) search of the
array, instead of strncasecmp().
With HTTP_HEADER_UNSPECIFIED removed, add optimization to set bit
in htags for HTTP_HEADER_OTHER when an "other" header is added,
but do not clear the bit, as there might be addtl "other" headers
Diffstat (limited to 'src/mod_extforward.c')
-rw-r--r-- | src/mod_extforward.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mod_extforward.c b/src/mod_extforward.c index 00d19c4d..1a6829c2 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -375,6 +375,15 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) { cpv->vtype = T_CONFIG_LOCAL; break; case 1: /* extforward.headers */ + if (cpv->v.a->used) { + array *a; + *(const array **)&a = cpv->v.a; + for (uint32_t j = 0; j < a->used; ++j) { + data_string * const ds = (data_string *)a->data[j]; + ds->ext = + http_header_hkey_get(CONST_BUF_LEN(&ds->value)); + } + } break; case 2: /* extforward.params */ cpv->v.u = mod_extforward_parse_opts(srv, cpv->v.a); @@ -1105,8 +1114,9 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) { return HANDLER_GO_ON; for (uint32_t k = 0; k < p->conf.headers->used; ++k) { - buffer *hdr = &((data_string *)p->conf.headers->data[k])->value; - forwarded = http_header_request_get(r, HTTP_HEADER_UNSPECIFIED, CONST_BUF_LEN(hdr)); + const data_string * const ds = (data_string *)p->conf.headers->data[k]; + const buffer * const hdr = &ds->value; + forwarded = http_header_request_get(r, ds->ext, CONST_BUF_LEN(hdr)); if (forwarded) { is_forwarded_header = buffer_is_equal_caseless_string(hdr, CONST_STR_LEN("Forwarded")); break; |