41
41
js_set $test_version test_version;
42
42
js_set $test_addr test_addr;
43
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
44
js_set $test_arg test_arg;
47
45
js_set $test_iarg test_iarg;
48
46
js_set $test_var test_var;
@@ -76,14 +74,6 @@ http {
76
74
return 200 $test_uri;
77
75
}
78
76
79
- location /hdr_in {
80
- return 200 $test_hdr_in;
81
- }
82
-
83
- location /ihdr_in {
84
- return 200 $test_ihdr_in;
85
- }
86
-
87
77
location /arg {
88
78
return 200 $test_arg;
89
79
}
@@ -113,22 +103,6 @@ http {
113
103
js_content status;
114
104
}
115
105
116
- location /ctype {
117
- js_content ctype;
118
- }
119
-
120
- location /clen {
121
- js_content clen;
122
- }
123
-
124
- location /hdr_out {
125
- js_content hdr_out;
126
- }
127
-
128
- location /ihdr_out {
129
- js_content ihdr_out;
130
- }
131
-
132
106
location /request_body {
133
107
js_content request_body;
134
108
}
@@ -141,10 +115,6 @@ http {
141
115
js_content return_method;
142
116
}
143
117
144
- location /return_headers {
145
- js_content return_headers;
146
- }
147
-
148
118
location /log {
149
119
return 200 $test_log;
150
120
}
@@ -188,20 +158,6 @@ $t->write_file('test.js', <<EOF);
188
158
return 'uri=' + r.uri;
189
159
}
190
160
191
- function test_hdr_in(r) {
192
- return 'hdr=' + r.headersIn.foo;
193
- }
194
-
195
- function test_ihdr_in(r) {
196
- var s = '', h;
197
- for (h in r.headersIn) {
198
- if (h.substr(0, 3) == 'foo') {
199
- s += r.headersIn[h];
200
- }
201
- }
202
- return s;
203
- }
204
-
205
161
function test_arg(r) {
206
162
return 'arg=' + r.args.foo;
207
163
}
@@ -230,49 +186,6 @@ $t->write_file('test.js', <<EOF);
230
186
r.finish();
231
187
}
232
188
233
- function ctype(r) {
234
- r.status = 200;
235
- r.headersOut['Content-Type'] = 'application/foo';
236
- r.sendHeader();
237
- r.finish();
238
- }
239
-
240
- function clen(r) {
241
- r.status = 200;
242
- r.headersOut['Content-Length'] = 5;
243
- r.sendHeader();
244
- r.send('foo12');
245
- r.finish();
246
- }
247
-
248
- function hdr_out(r) {
249
- r.status = 200;
250
- r.headersOut['Foo'] = r.args.fOO;
251
-
252
- if (r.args.bar) {
253
- r.headersOut['Bar'] =
254
- r.headersOut[(r.args.bar == 'empty' ? 'Baz' :'Foo')]
255
- }
256
-
257
- r.sendHeader();
258
- r.finish();
259
- }
260
-
261
- function ihdr_out(r) {
262
- r.status = 200;
263
- r.headersOut['a'] = r.args.a;
264
- r.headersOut['b'] = r.args.b;
265
-
266
- var s = '', h;
267
- for (h in r.headersOut) {
268
- s += r.headersOut[h];
269
- }
270
-
271
- r.sendHeader();
272
- r.send(s);
273
- r.finish();
274
- }
275
-
276
189
function request_body(r) {
277
190
try {
278
191
var body = r.requestBody;
@@ -300,11 +213,6 @@ $t->write_file('test.js', <<EOF);
300
213
r.return(Number(r.args.c), r.args.t);
301
214
}
302
215
303
- function return_headers(r) {
304
- r.headersOut.Foo = 'bar';
305
- r.return(200);
306
- }
307
-
308
216
function test_log(r) {
309
217
r.log('SEE-THIS');
310
218
}
@@ -324,7 +232,7 @@ $t->write_file('test.js', <<EOF);
324
232
325
233
EOF
326
234
327
- $t -> try_run(' no njs available' )-> plan(35 );
235
+ $t -> try_run(' no njs available' )-> plan(23 );
328
236
329
237
# ##############################################################################
330
238
@@ -333,29 +241,10 @@ like(http_get('/method'), qr/method=GET/, 'r.method');
333
241
like(http_get(' /version' ), qr / version=1.0/ , ' r.httpVersion' );
334
242
like(http_get(' /addr' ), qr / addr=127.0.0.1/ , ' r.remoteAddress' );
335
243
like(http_get(' /uri' ), qr / uri=\/ uri/ , ' r.uri' );
336
- like(http_get_hdr(' /hdr_in' ), qr / hdr=12345/ , ' r.headersIn' );
337
- like(http_get_ihdr(' /ihdr_in' ), qr / 12345barz/ , ' r.headersIn iteration' );
338
244
like(http_get(' /arg?foO=12345' ), qr / arg=12345/ , ' r.args' );
339
245
like(http_get(' /iarg?foo=12345&foo2=bar&nn=22&foo-3=z' ), qr / 12345barz/ ,
340
246
' r.args iteration' );
341
247
like(http_get(' /status' ), qr / 204 No Content/ , ' r.status' );
342
- like(http_get(' /ctype' ), qr / Content-Type: application\/ foo/ ,
343
- ' r.headersOut.contentType' );
344
- like(http_get(' /clen' ), qr / Content-Length: 5/ , ' r.headersOut.contentLength' );
345
- like(http_get(' /hdr_out?foo=12345' ), qr / Foo: 12345/ , ' r.headersOut' );
346
- like(http_get(' /hdr_out?foo=123&bar=copy' ), qr / Bar: 123/ , ' r.headersOut get' );
347
- like(http_get(' /ihdr_out?a=12&b=34' ), qr / ^1234$ / m , ' r.headersOut iteration' );
348
- like(http_get(' /ihdr_out' ), qr /\x0d\x0a ?\x0d\x0a ?$ / m , ' r.send zero' );
349
-
350
- TODO: {
351
- local $TODO = ' not yet'
352
- unless http_get(' /njs' ) =~ / ^([.0-9]+)$ /m && $1 ge ' 0.2.8' ;
353
-
354
- unlike(http_get(' /hdr_out?bar=empty' ), qr / Bar:/ , ' r.headersOut empty' );
355
- unlike(http_get(' /hdr_out?foo=' ), qr / Foo:/ , ' r.headersOut no value' );
356
- unlike(http_get(' /hdr_out?foo' ), qr / Foo:/ , ' r.headersOut no value 2' );
357
-
358
- }
359
248
360
249
like(http_post(' /body' ), qr / REQ-BODY/ , ' request body' );
361
250
like(http_post(' /in_file' ), qr / request body is in a file/ ,
@@ -375,8 +264,6 @@ like(http_get('/return_method?c=301&t=path'), qr/ 301 .*Location: path/s,
375
264
like(http_get(' /return_method?c=404' ), qr / 404 Not.*html/ s , ' return error page' );
376
265
like(http_get(' /return_method?c=inv' ), qr / 500 / , ' return invalid' );
377
266
378
- like(http_get(' /return_headers' ), qr / Foo: bar/ , ' return headers' );
379
-
380
267
like(http_get(' /var' ), qr / variable=127.0.0.1/ , ' r.variables' );
381
268
like(http_get(' /global' ), qr / global=njs/ , ' global code' );
382
269
like(http_get(' /log' ), qr / 200 OK/ , ' r.log' );
0 commit comments