@@ -61,6 +61,10 @@ http {
61
61
js_content test.fetch;
62
62
}
63
63
64
+ location /fetch_multi_header {
65
+ js_content test.fetch_multi_header;
66
+ }
67
+
64
68
location /method {
65
69
return 200 $request_method;
66
70
}
@@ -489,24 +493,32 @@ $t->write_file('test.js', <<EOF);
489
493
var body = await r.text();
490
494
return `\$ {r.url}: \$ {r.status} \$ {body}`;
491
495
}, 'http://127.0.0.1:$p0 /body: 201 foo'],
492
- ['request body', async () => {
496
+ ];
497
+
498
+ run(r, tests);
499
+ }
500
+
501
+ async function fetch_multi_header(r) {
502
+ const tests = [
503
+ ['request multi header', async () => {
493
504
var h = new Headers({a: 'X'});
494
505
h.append('a', 'Z');
495
506
var req = new Request("http://127.0.0.1:$p0 /header",
496
507
{headers: h});
497
- var r = await ngx.fetch(req);
498
- var body = await r.text();
508
+ var r = await ngx.fetch(req);
509
+ var body = await r.text();
499
510
return `\$ {r.url}: \$ {r.status} \$ {body}`;
500
511
}, 'http://127.0.0.1:$p0 /header: 200 X, Z'],
501
512
];
502
513
503
514
run(r, tests);
504
515
}
505
516
506
- export default {njs: test_njs, body, headers, request, response, fetch};
517
+ export default {njs: test_njs, body, headers, request, response, fetch,
518
+ fetch_multi_header};
507
519
EOF
508
520
509
- $t -> try_run(' no njs' )-> plan(4 );
521
+ $t -> try_run(' no njs' )-> plan(5 );
510
522
511
523
# ##############################################################################
512
524
@@ -517,6 +529,14 @@ like(http_get('/request'), qr/200 OK/s, 'request tests');
517
529
like(http_get(' /response' ), qr / 200 OK/ s , ' response tests' );
518
530
like(http_get(' /fetch' ), qr / 200 OK/ s , ' fetch tests' );
519
531
532
+ TODO: {
533
+ local $TODO = ' not yet' unless $t -> has_version(' 1.23.0' );
534
+
535
+ like(http_get(' /fetch_multi_header' ), qr / 200 OK/ s ,
536
+ ' fetch multi header tests' );
537
+
538
+ }
539
+
520
540
# ##############################################################################
521
541
522
542
sub has_version {
0 commit comments