Mercurial > hg > nginx-tests
comparison js_headers.t @ 1751:18ac4d9e5a2a
Tests: rewriting njs tests without deprecated "js_include".
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 09 Dec 2021 17:36:29 +0000 |
parents | 4cc012205ac5 |
children | c0dfbedf52bd |
comparison
equal
deleted
inserted
replaced
1750:b28f88e352dd | 1751:18ac4d9e5a2a |
---|---|
35 } | 35 } |
36 | 36 |
37 http { | 37 http { |
38 %%TEST_GLOBALS_HTTP%% | 38 %%TEST_GLOBALS_HTTP%% |
39 | 39 |
40 js_set $test_foo_in test_foo_in; | 40 js_set $test_foo_in test.foo_in; |
41 js_set $test_ifoo_in test_ifoo_in; | 41 js_set $test_ifoo_in test.ifoo_in; |
42 | 42 |
43 js_include test.js; | 43 js_import test.js; |
44 | 44 |
45 server { | 45 server { |
46 listen 127.0.0.1:8080; | 46 listen 127.0.0.1:8080; |
47 server_name localhost; | 47 server_name localhost; |
48 | 48 |
49 location /njs { | 49 location /njs { |
50 js_content test_njs; | 50 js_content test.njs; |
51 } | 51 } |
52 | 52 |
53 location /content_length { | 53 location /content_length { |
54 js_content content_length; | 54 js_content test.content_length; |
55 } | 55 } |
56 | 56 |
57 location /content_length_arr { | 57 location /content_length_arr { |
58 js_content content_length_arr; | 58 js_content test.content_length_arr; |
59 } | 59 } |
60 | 60 |
61 location /content_length_keys { | 61 location /content_length_keys { |
62 js_content content_length_keys; | 62 js_content test.content_length_keys; |
63 } | 63 } |
64 | 64 |
65 location /content_type { | 65 location /content_type { |
66 charset windows-1251; | 66 charset windows-1251; |
67 | 67 |
68 default_type text/plain; | 68 default_type text/plain; |
69 js_content content_type; | 69 js_content test.content_type; |
70 } | 70 } |
71 | 71 |
72 location /content_type_arr { | 72 location /content_type_arr { |
73 charset windows-1251; | 73 charset windows-1251; |
74 | 74 |
75 default_type text/plain; | 75 default_type text/plain; |
76 js_content content_type_arr; | 76 js_content test.content_type_arr; |
77 } | 77 } |
78 | 78 |
79 location /content_encoding { | 79 location /content_encoding { |
80 js_content content_encoding; | 80 js_content test.content_encoding; |
81 } | 81 } |
82 | 82 |
83 location /content_encoding_arr { | 83 location /content_encoding_arr { |
84 js_content content_encoding_arr; | 84 js_content test.content_encoding_arr; |
85 } | 85 } |
86 | 86 |
87 location /headers_list { | 87 location /headers_list { |
88 js_content headers_list; | 88 js_content test.headers_list; |
89 } | 89 } |
90 | 90 |
91 location /foo_in { | 91 location /foo_in { |
92 return 200 $test_foo_in; | 92 return 200 $test_foo_in; |
93 } | 93 } |
95 location /ifoo_in { | 95 location /ifoo_in { |
96 return 200 $test_ifoo_in; | 96 return 200 $test_ifoo_in; |
97 } | 97 } |
98 | 98 |
99 location /hdr_in { | 99 location /hdr_in { |
100 js_content hdr_in; | 100 js_content test.hdr_in; |
101 } | 101 } |
102 | 102 |
103 location /raw_hdr_in { | 103 location /raw_hdr_in { |
104 js_content raw_hdr_in; | 104 js_content test.raw_hdr_in; |
105 } | 105 } |
106 | 106 |
107 location /hdr_out { | 107 location /hdr_out { |
108 js_content hdr_out; | 108 js_content test.hdr_out; |
109 } | 109 } |
110 | 110 |
111 location /raw_hdr_out { | 111 location /raw_hdr_out { |
112 js_content raw_hdr_out; | 112 js_content test.raw_hdr_out; |
113 } | 113 } |
114 | 114 |
115 location /hdr_out_array { | 115 location /hdr_out_array { |
116 js_content hdr_out_array; | 116 js_content test.hdr_out_array; |
117 } | 117 } |
118 | 118 |
119 location /hdr_out_set_cookie { | 119 location /hdr_out_set_cookie { |
120 js_content hdr_out_set_cookie; | 120 js_content test.hdr_out_set_cookie; |
121 } | 121 } |
122 | 122 |
123 location /hdr_out_single { | 123 location /hdr_out_single { |
124 js_content hdr_out_single; | 124 js_content test.hdr_out_single; |
125 } | 125 } |
126 | 126 |
127 location /ihdr_out { | 127 location /ihdr_out { |
128 js_content ihdr_out; | 128 js_content test.ihdr_out; |
129 } | 129 } |
130 | 130 |
131 location /hdr_sorted_keys { | 131 location /hdr_sorted_keys { |
132 js_content hdr_sorted_keys; | 132 js_content test.hdr_sorted_keys; |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 EOF | 137 EOF |
241 } | 241 } |
242 | 242 |
243 r.return(200, Object.keys(hdr).sort()); | 243 r.return(200, Object.keys(hdr).sort()); |
244 } | 244 } |
245 | 245 |
246 function test_foo_in(r) { | 246 function foo_in(r) { |
247 return 'hdr=' + r.headersIn.foo; | 247 return 'hdr=' + r.headersIn.foo; |
248 } | 248 } |
249 | 249 |
250 function test_ifoo_in(r) { | 250 function ifoo_in(r) { |
251 var s = '', h; | 251 var s = '', h; |
252 for (h in r.headersIn) { | 252 for (h in r.headersIn) { |
253 if (h.substr(0, 3) == 'foo') { | 253 if (h.substr(0, 3) == 'foo') { |
254 s += r.headersIn[h]; | 254 s += r.headersIn[h]; |
255 } | 255 } |
320 | 320 |
321 r.sendHeader(); | 321 r.sendHeader(); |
322 r.send(s); | 322 r.send(s); |
323 r.finish(); | 323 r.finish(); |
324 } | 324 } |
325 | |
326 export default {njs:test_njs, content_length, content_length_arr, | |
327 content_length_keys, content_type, content_type_arr, | |
328 content_encoding, content_encoding_arr, headers_list, | |
329 hdr_in, raw_hdr_in, hdr_sorted_keys, foo_in, ifoo_in, | |
330 hdr_out, raw_hdr_out, hdr_out_array, hdr_out_single, | |
331 hdr_out_set_cookie, ihdr_out}; | |
325 | 332 |
326 | 333 |
327 EOF | 334 EOF |
328 | 335 |
329 $t->try_run('no njs')->plan(39); | 336 $t->try_run('no njs')->plan(39); |