@@ -131,6 +131,20 @@ http {
131
131
location /hdr_sorted_keys {
132
132
js_content test.hdr_sorted_keys;
133
133
}
134
+
135
+ location /hdr_out_special_set {
136
+ js_content test.hdr_out_special_set;
137
+ }
138
+
139
+ location /copy_subrequest_hdrs {
140
+ js_content test.copy_subrequest_hdrs;
141
+ }
142
+
143
+ location = /subrequest {
144
+ internal;
145
+
146
+ js_content test.subrequest;
147
+ }
134
148
}
135
149
}
136
150
@@ -350,17 +364,50 @@ $t->write_file('test.js', <<EOF);
350
364
r.finish();
351
365
}
352
366
367
+ function hdr_out_special_set(r) {
368
+ r.headersOut['Foo'] = "xxx";
369
+ r.headersOut['Content-Encoding'] = 'abc';
370
+
371
+ let ce = r.headersOut['Content-Encoding'];
372
+ r.return(200, `CE: \$ {ce}`);
373
+ }
374
+
375
+ async function copy_subrequest_hdrs(r) {
376
+ let resp = await r.subrequest("/subrequest");
377
+
378
+ for (const h in resp.headersOut) {
379
+ r.headersOut[h] = resp.headersOut[h];
380
+ }
381
+
382
+ r.return(200, resp.responseBody);
383
+ }
384
+
385
+ function subrequest(r) {
386
+ r.headersOut['A'] = 'a';
387
+ r.headersOut['Content-Encoding'] = 'ce';
388
+ r.headersOut['B'] = 'b';
389
+ r.headersOut['C'] = 'c';
390
+ r.headersOut['D'] = 'd';
391
+ r.headersOut['Set-Cookie'] = ['A', 'BB'];
392
+ r.headersOut['Content-Length'] = 3;
393
+ r.headersOut['Content-Type'] = 'ct';
394
+ r.sendHeader();
395
+ r.send('XXX');
396
+ r.finish();
397
+ }
398
+
353
399
export default {njs:test_njs, content_length, content_length_arr,
354
400
content_length_keys, content_type, content_type_arr,
355
401
content_encoding, content_encoding_arr, headers_list,
356
402
hdr_in, raw_hdr_in, hdr_sorted_keys, foo_in, ifoo_in,
357
403
hdr_out, raw_hdr_out, hdr_out_array, hdr_out_single,
358
- hdr_out_set_cookie, ihdr_out};
404
+ hdr_out_set_cookie, ihdr_out, hdr_out_special_set,
405
+ copy_subrequest_hdrs, subrequest};
359
406
360
407
361
408
EOF
362
409
363
- $t -> try_run(' no njs' )-> plan(39 );
410
+ $t -> try_run(' no njs' )-> plan(42 );
364
411
365
412
# ##############################################################################
366
413
@@ -495,4 +542,21 @@ like(http(
495
542
. ' Host: localhost' . CRLF . CRLF
496
543
), qr / a,b,c/ , ' r.headersOut sorted keys' );
497
544
545
+ TODO: {
546
+ local $TODO = ' not yet'
547
+ unless http_get(' /njs' ) =~ / ^([.0-9]+)$ /m && $1 ge ' 0.7.6' ;
548
+
549
+ like(http_get(' /hdr_out_special_set' ), qr / CE: abc/ ,
550
+ ' r.headerOut special set' );
551
+
552
+ like(http_get(' /copy_subrequest_hdrs' ),
553
+ qr / A: a.*B: b.*C: c.*D: d.*Set-Cookie: A.*Set-Cookie: BB/ s ,
554
+ ' subrequest copy' );
555
+
556
+ like(http_get(' /copy_subrequest_hdrs' ),
557
+ qr / Content-Type: ct.*Content-Encoding: ce.*Content-Length: 3/ s ,
558
+ ' subrequest copy special' );
559
+
560
+ }
561
+
498
562
# ##############################################################################
0 commit comments