From: Dmitry Volyntsev Date: Sat, 22 Feb 2025 07:03:46 +0000 (-0800) Subject: Fetch: accepting response headers with underscore characters. X-Git-Tag: 0.8.10~24 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=18977e022b2a9f9f03c2dc5ae4bbc930a2f30855;p=njs.git Fetch: accepting response headers with underscore characters. This fixes #856 on Github. --- diff --git a/nginx/ngx_js_fetch.c b/nginx/ngx_js_fetch.c index 1c5a961d..cd6e54f6 100644 --- a/nginx/ngx_js_fetch.c +++ b/nginx/ngx_js_fetch.c @@ -2868,7 +2868,7 @@ ngx_js_http_parse_header_line(ngx_js_http_parse_t *hp, ngx_buf_t *b) break; } - if (ch == '-') { + if (ch == '-' || ch == '_') { break; } diff --git a/nginx/t/js_fetch.t b/nginx/t/js_fetch.t index 0e107c89..ae9d1f61 100644 --- a/nginx/t/js_fetch.t +++ b/nginx/t/js_fetch.t @@ -413,7 +413,7 @@ $t->try_run('no njs.fetch'); plan(skip_all => 'not yet') if http_get('/engine') =~ /QuickJS$/m; -$t->plan(36); +$t->plan(37); $t->run_daemon(\&http_daemon, port(8082)); $t->waitforsocket('127.0.0.1:' . port(8082)); @@ -479,6 +479,8 @@ like(http_get('/chain'), qr/200 OK.*SUCCESS$/s, 'fetch chain'); like(http_get('/header_iter?loc=duplicate_header_large'), qr/\["A:a","B:a","C:a","D:a","E:a","F:a","G:a","H:a","Moo:a, ?b"]$/s, 'fetch header duplicate large'); +like(http_get('/header_iter?loc=underscore_header'), + qr/\["F_O_O:b","Foo:a"]$/s, 'fetch header underscore'); TODO: { local $TODO = 'not yet' unless has_version('0.7.7'); @@ -621,6 +623,14 @@ sub http_daemon { "Connection: close" . CRLF . CRLF; + } elsif ($uri eq '/underscore_header') { + print $client + "HTTP/1.1 200 OK" . CRLF . + "Foo: a" . CRLF . + "F_O_O: b" . CRLF . + "Connection: close" . CRLF . + CRLF; + } elsif ($uri eq '/headers') { print $client "HTTP/1.1 200 OK" . CRLF .