@@ -37,17 +37,17 @@ events {
37
37
http {
38
38
%%TEST_GLOBALS_HTTP%%
39
39
40
- js_set $test_method test_method;
41
- js_set $test_version test_version;
42
- js_set $test_addr test_addr;
43
- js_set $test_uri test_uri;
44
- js_set $test_hdr test_hdr ;
45
- js_set $test_ihdr test_ihdr ;
46
- js_set $test_arg test_arg;
47
- js_set $test_iarg test_iarg;
48
- js_set $test_var test_var;
49
- js_set $test_log test_log;
50
- js_set $test_except test_except;
40
+ js_set $test_method test_method;
41
+ js_set $test_version test_version;
42
+ js_set $test_addr test_addr;
43
+ js_set $test_uri test_uri;
44
+ js_set $test_hdr_in test_hdr_in ;
45
+ js_set $test_ihdr_in test_ihdr_in ;
46
+ js_set $test_arg test_arg;
47
+ js_set $test_iarg test_iarg;
48
+ js_set $test_var test_var;
49
+ js_set $test_log test_log;
50
+ js_set $test_except test_except;
51
51
52
52
js_include test.js;
53
53
@@ -76,11 +76,11 @@ http {
76
76
}
77
77
78
78
location /hdr_in {
79
- return 200 $test_hdr ;
79
+ return 200 $test_hdr_in ;
80
80
}
81
81
82
82
location /ihdr_in {
83
- return 200 $test_ihdr ;
83
+ return 200 $test_ihdr_in ;
84
84
}
85
85
86
86
location /arg {
@@ -132,7 +132,7 @@ http {
132
132
js_content send;
133
133
}
134
134
135
- location /return {
135
+ location /return_method {
136
136
js_content return_method;
137
137
}
138
138
@@ -144,7 +144,7 @@ http {
144
144
return 200 $test_log;
145
145
}
146
146
147
- location /var_except {
147
+ location /except {
148
148
return 200 $test_except;
149
149
}
150
150
@@ -181,11 +181,11 @@ $t->write_file('test.js', <<EOF);
181
181
return 'uri=' + r.uri;
182
182
}
183
183
184
- function test_hdr (r) {
184
+ function test_hdr_in (r) {
185
185
return 'hdr=' + r.headersIn.foo;
186
186
}
187
187
188
- function test_ihdr (r) {
188
+ function test_ihdr_in (r) {
189
189
var s = '', h;
190
190
for (h in r.headersIn) {
191
191
if (h.substr(0, 3) == 'foo') {
@@ -215,8 +215,6 @@ $t->write_file('test.js', <<EOF);
215
215
216
216
function status(r) {
217
217
r.status = 204;
218
- if (r.status != 204)
219
- r.status = 404;
220
218
r.sendHeader();
221
219
r.finish();
222
220
}
@@ -231,8 +229,6 @@ $t->write_file('test.js', <<EOF);
231
229
function clen(r) {
232
230
r.status = 200;
233
231
r.headersOut['Content-Length'] = 5;
234
- if (r.headersOut['Content-Length'] != 5)
235
- r.headersOut['Content-Length'] = 6;
236
232
r.sendHeader();
237
233
r.send('foo12');
238
234
r.finish();
@@ -243,11 +239,8 @@ $t->write_file('test.js', <<EOF);
243
239
r.headersOut['Foo'] = r.args.fOO;
244
240
245
241
if (r.args.bar) {
246
- r.headersOut['Bar'] = r.headersOut['Foo'];
247
- }
248
-
249
- if (r.args.bar == 'empty') {
250
- r.headersOut['Bar'] = r.headersOut['Baz'];
242
+ r.headersOut['Bar'] =
243
+ r.headersOut[(r.args.bar == 'empty' ? 'Baz' :'Foo')]
251
244
}
252
245
253
246
r.sendHeader();
@@ -302,7 +295,7 @@ $t->write_file('test.js', <<EOF);
302
295
}
303
296
304
297
function test_log(r) {
305
- r.log(" SEE-THIS" );
298
+ r.log(' SEE-THIS' );
306
299
}
307
300
308
301
function test_except(r) {
@@ -320,7 +313,7 @@ $t->write_file('test.js', <<EOF);
320
313
321
314
EOF
322
315
323
- $t -> try_run(' no njs available' )-> plan(32 );
316
+ $t -> try_run(' no njs available' )-> plan(34 );
324
317
325
318
# ##############################################################################
326
319
@@ -344,42 +337,48 @@ like(http_get('/clen'), qr/Content-Length: 5/, 'r.headersOut.contentLength');
344
337
like(http_get(' /hdr_out?foo=12345' ), qr / Foo: 12345/ , ' r.headersOut' );
345
338
like(http_get(' /hdr_out?foo=123&bar=copy' ), qr / Bar: 123/ , ' r.headersOut get' );
346
339
like(http_get(' /hdr_out?bar=empty' ), qr / Bar: \x0d / , ' r.headersOut empty' );
340
+ like(http_get(' /hdr_out?foo=' ), qr / Foo: \x0d / , ' r.headersOut no value' );
341
+ like(http_get(' /hdr_out?foo' ), qr / Foo: \x0d / , ' r.headersOut no value 2' );
347
342
like(http_get(' /ihdr_out?a=12&b=34' ), qr / ^1234$ / m , ' r.headersOut iteration' );
348
343
like(http_get(' /ihdr_out' ), qr /\x0d\x0a ?\x0d\x0a ?$ / m , ' r.send zero' );
349
344
350
345
like(http_post(' /body' ), qr / REQ-BODY/ , ' request body' );
351
346
like(http_post(' /in_file' ), qr / request body is in a file/ ,
352
347
' request body in file' );
353
348
like(http_post_big(' /body' ), qr / 200.*^(1234567890){1024}$ / ms ,
354
- ' request body big' );
349
+ ' request body big' );
355
350
356
351
like(http_get(' /send?foo=12345&n=11&foo-2=bar&ndd=&foo-3=z' ),
357
352
qr / n=foo, v=12 n=foo-2, v=ba n=foo-3, v=z/ , ' r.send' );
358
353
359
- like(http_get(' /return?c=200' ), qr / 200 OK.*\x0d\x0a ?\x0d\x0a ?$ / s , ' return code' );
360
- like(http_get(' /return?c=200&t=SEE-THIS' ), qr / 200 OK.*^SEE-THIS$ / ms , ' return text' );
361
- like(http_get(' /return?c=301&t=path' ), qr / 301 .*Location: path/ s , ' return redirect' );
362
- like(http_get(' /return?c=404' ), qr / 404 Not.*html/ s , ' return error page' );
363
- like(http_get(' /return?c=inv' ), qr / 500 / , ' return invalid' );
354
+ like(http_get(' /return_method?c=200' ), qr / 200 OK.*\x0d\x0a ?\x0d\x0a ?$ / s ,
355
+ ' return code' );
356
+ like(http_get(' /return_method?c=200&t=SEE-THIS' ), qr / 200 OK.*^SEE-THIS$ / ms ,
357
+ ' return text' );
358
+ like(http_get(' /return_method?c=301&t=path' ), qr / 301 .*Location: path/ s ,
359
+ ' return redirect' );
360
+ like(http_get(' /return_method?c=404' ), qr / 404 Not.*html/ s , ' return error page' );
361
+ like(http_get(' /return_method?c=inv' ), qr / 500 / , ' return invalid' );
364
362
365
363
like(http_get(' /return_headers' ), qr / Foo: bar/ , ' return headers' );
366
364
367
365
like(http_get(' /var' ), qr / variable=127.0.0.1/ , ' r.variables' );
368
366
like(http_get(' /log' ), qr / 200 OK/ , ' r.log' );
369
367
370
- http_get(' /var_except ' );
368
+ http_get(' /except ' );
371
369
http_get(' /content_except' );
372
370
373
- like(http_get(' /content_empty' ), qr / 500 Internal Server Error/ , ' empty handler' );
371
+ like(http_get(' /content_empty' ), qr / 500 Internal Server Error/ ,
372
+ ' empty handler' );
374
373
}
375
374
376
375
$t -> stop();
377
376
378
377
ok(index ($t -> read_file(' error.log' ), ' SEE-THIS' ) > 0, ' log js' );
379
378
ok(index ($t -> read_file(' error.log' ), ' at fs.readFileSync' ) > 0,
380
- ' js_set backtrace' );
379
+ ' js_set backtrace' );
381
380
ok(index ($t -> read_file(' error.log' ), ' at JSON.parse' ) > 0,
382
- ' js_content backtrace' );
381
+ ' js_content backtrace' );
383
382
384
383
# ##############################################################################
385
384
0 commit comments