Mercurial > hg > nginx-tests
changeset 1775:eacfd2b64b71
Tests: added js headers test for multiple special headers set.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Wed, 06 Jul 2022 15:51:40 -0700 |
parents | 5a625ce0de34 |
children | f89770df737a |
files | js_headers.t |
diffstat | 1 files changed, 66 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/js_headers.t Mon Jun 13 15:13:30 2022 +0400 +++ b/js_headers.t Wed Jul 06 15:51:40 2022 -0700 @@ -131,6 +131,20 @@ location /hdr_sorted_keys { js_content test.hdr_sorted_keys; } + + location /hdr_out_special_set { + js_content test.hdr_out_special_set; + } + + location /copy_subrequest_hdrs { + js_content test.copy_subrequest_hdrs; + } + + location = /subrequest { + internal; + + js_content test.subrequest; + } } } @@ -350,17 +364,50 @@ r.finish(); } + function hdr_out_special_set(r) { + r.headersOut['Foo'] = "xxx"; + r.headersOut['Content-Encoding'] = 'abc'; + + let ce = r.headersOut['Content-Encoding']; + r.return(200, `CE: \${ce}`); + } + + async function copy_subrequest_hdrs(r) { + let resp = await r.subrequest("/subrequest"); + + for (const h in resp.headersOut) { + r.headersOut[h] = resp.headersOut[h]; + } + + r.return(200, resp.responseBody); + } + + function subrequest(r) { + r.headersOut['A'] = 'a'; + r.headersOut['Content-Encoding'] = 'ce'; + r.headersOut['B'] = 'b'; + r.headersOut['C'] = 'c'; + r.headersOut['D'] = 'd'; + r.headersOut['Set-Cookie'] = ['A', 'BB']; + r.headersOut['Content-Length'] = 3; + r.headersOut['Content-Type'] = 'ct'; + r.sendHeader(); + r.send('XXX'); + r.finish(); + } + export default {njs:test_njs, content_length, content_length_arr, content_length_keys, content_type, content_type_arr, content_encoding, content_encoding_arr, headers_list, hdr_in, raw_hdr_in, hdr_sorted_keys, foo_in, ifoo_in, hdr_out, raw_hdr_out, hdr_out_array, hdr_out_single, - hdr_out_set_cookie, ihdr_out}; + hdr_out_set_cookie, ihdr_out, hdr_out_special_set, + copy_subrequest_hdrs, subrequest}; EOF -$t->try_run('no njs')->plan(39); +$t->try_run('no njs')->plan(42); ############################################################################### @@ -495,4 +542,21 @@ . 'Host: localhost' . CRLF . CRLF ), qr/a,b,c/, 'r.headersOut sorted keys'); +TODO: { +local $TODO = 'not yet' + unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.6'; + +like(http_get('/hdr_out_special_set'), qr/CE: abc/, + 'r.headerOut special set'); + +like(http_get('/copy_subrequest_hdrs'), + qr/A: a.*B: b.*C: c.*D: d.*Set-Cookie: A.*Set-Cookie: BB/s, + 'subrequest copy'); + +like(http_get('/copy_subrequest_hdrs'), + qr/Content-Type: ct.*Content-Encoding: ce.*Content-Length: 3/s, + 'subrequest copy special'); + +} + ###############################################################################