Skip to content

Commit 18977e0

Browse files
committed
Fetch: accepting response headers with underscore characters.
This fixes #856 on Github.
1 parent 3045f31 commit 18977e0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

nginx/ngx_js_fetch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ ngx_js_http_parse_header_line(ngx_js_http_parse_t *hp, ngx_buf_t *b)
28682868
break;
28692869
}
28702870

2871-
if (ch == '-') {
2871+
if (ch == '-' || ch == '_') {
28722872
break;
28732873
}
28742874

nginx/t/js_fetch.t

+11-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ $t->try_run('no njs.fetch');
413413

414414
plan(skip_all => 'not yet') if http_get('/engine') =~ /QuickJS$/m;
415415

416-
$t->plan(36);
416+
$t->plan(37);
417417

418418
$t->run_daemon(\&http_daemon, port(8082));
419419
$t->waitforsocket('127.0.0.1:' . port(8082));
@@ -479,6 +479,8 @@ like(http_get('/chain'), qr/200 OK.*SUCCESS$/s, 'fetch chain');
479479
like(http_get('/header_iter?loc=duplicate_header_large'),
480480
qr/\["A:a","B:a","C:a","D:a","E:a","F:a","G:a","H:a","Moo:a, ?b"]$/s,
481481
'fetch header duplicate large');
482+
like(http_get('/header_iter?loc=underscore_header'),
483+
qr/\["F_O_O:b","Foo:a"]$/s, 'fetch header underscore');
482484

483485
TODO: {
484486
local $TODO = 'not yet' unless has_version('0.7.7');
@@ -621,6 +623,14 @@ sub http_daemon {
621623
"Connection: close" . CRLF .
622624
CRLF;
623625

626+
} elsif ($uri eq '/underscore_header') {
627+
print $client
628+
"HTTP/1.1 200 OK" . CRLF .
629+
"Foo: a" . CRLF .
630+
"F_O_O: b" . CRLF .
631+
"Connection: close" . CRLF .
632+
CRLF;
633+
624634
} elsif ($uri eq '/headers') {
625635
print $client
626636
"HTTP/1.1 200 OK" . CRLF .

0 commit comments

Comments
 (0)