Tests: removed js tests for deprecated njs API.
diff --git a/js.t b/js.t
index f1a807a..aa35e3f 100644
--- a/js.t
+++ b/js.t
@@ -1,6 +1,8 @@
#!/usr/bin/perl
# (C) Roman Arutyunyan
+# (C) Dmitry Volyntsev
+# (C) Nginx, Inc.
# Tests for http njs module.
@@ -10,6 +12,7 @@
use strict;
use Test::More;
+use Socket qw/ CRLF /;
BEGIN { use FindBin; chdir($FindBin::Bin); }
@@ -34,17 +37,18 @@
http {
%%TEST_GLOBALS_HTTP%%
- js_set $test_method test_method;
- js_set $test_version test_version;
- js_set $test_addr test_addr;
- js_set $test_uri test_uri;
- js_set $test_hdr test_hdr;
- js_set $test_ihdr test_ihdr;
- js_set $test_arg test_arg;
- js_set $test_iarg test_iarg;
- js_set $test_var test_var;
- js_set $test_log test_log;
- js_set $test_except test_except;
+ js_set $test_method test_method;
+ js_set $test_version test_version;
+ js_set $test_addr test_addr;
+ js_set $test_uri test_uri;
+ js_set $test_hdr_in test_hdr_in;
+ js_set $test_ihdr_in test_ihdr_in;
+ js_set $test_arg test_arg;
+ js_set $test_iarg test_iarg;
+ js_set $test_var test_var;
+ js_set $test_global test_global;
+ js_set $test_log test_log;
+ js_set $test_except test_except;
js_include test.js;
@@ -56,271 +60,337 @@
js_content test_njs;
}
- location /req_method {
+ location /method {
return 200 $test_method;
}
- location /req_version {
+ location /version {
return 200 $test_version;
}
- location /req_addr {
+ location /addr {
return 200 $test_addr;
}
- location /req_uri {
+ location /uri {
return 200 $test_uri;
}
- location /req_hdr {
- return 200 $test_hdr;
+ location /hdr_in {
+ return 200 $test_hdr_in;
}
- location /req_ihdr {
- return 200 $test_ihdr;
+ location /ihdr_in {
+ return 200 $test_ihdr_in;
}
- location /req_arg {
+ location /arg {
return 200 $test_arg;
}
- location /req_iarg {
+ location /iarg {
return 200 $test_iarg;
}
- location /req_var {
+ location /var {
return 200 $test_var;
}
- location /req_log {
- return 200 $test_log;
+ location /global {
+ return 200 $test_global;
}
- location /req_except {
- return 200 $test_except;
+ location /body {
+ js_content request_body;
}
- location /req_empty {
- js_content content_empty;
+ location /in_file {
+ client_body_in_file_only on;
+ js_content request_body;
}
- location /res_status {
+ location /status {
js_content status;
}
- location /res_ctype {
+ location /ctype {
js_content ctype;
}
- location /res_clen {
+ location /clen {
js_content clen;
}
- location /res_send {
+ location /hdr_out {
+ js_content hdr_out;
+ }
+
+ location /ihdr_out {
+ js_content ihdr_out;
+ }
+
+ location /request_body {
+ js_content request_body;
+ }
+
+ location /send {
js_content send;
}
- location /res_hdr {
- js_content hdr;
+ location /return_method {
+ js_content return_method;
}
- location /res_ihdr {
- js_content ihdr;
+ location /return_headers {
+ js_content return_headers;
}
- location /res_except {
+ location /log {
+ return 200 $test_log;
+ }
+
+ location /except {
+ return 200 $test_except;
+ }
+
+ location /content_except {
js_content content_except;
}
+
+ location /content_empty {
+ js_content content_empty;
+ }
}
}
EOF
$t->write_file('test.js', <<EOF);
- function test_njs(req, res) {
- res.return(200, njs.version);
+ var global = ['n', 'j', 's'].join("");
+
+ function test_njs(r) {
+ r.return(200, njs.version);
}
- function test_method(req, res) {
- return 'method=' + req.method;
+ function test_method(r) {
+ return 'method=' + r.method;
}
- function test_version(req, res) {
- return 'version=' + req.httpVersion;
+ function test_version(r) {
+ return 'version=' + r.httpVersion;
}
- function test_addr(req, res) {
- return 'addr=' + req.remoteAddress;
+ function test_addr(r) {
+ return 'addr=' + r.remoteAddress;
}
- function test_uri(req, res) {
- return 'uri=' + req.uri;
+ function test_uri(r) {
+ return 'uri=' + r.uri;
}
- function test_hdr(req, res) {
- return 'hdr=' + req.headers.foo;
+ function test_hdr_in(r) {
+ return 'hdr=' + r.headersIn.foo;
}
- function test_ihdr(req, res) {
+ function test_ihdr_in(r) {
var s = '', h;
- for (h in req.headers) {
+ for (h in r.headersIn) {
if (h.substr(0, 3) == 'foo') {
- s += req.headers[h];
+ s += r.headersIn[h];
}
}
return s;
}
- function test_arg(req, res) {
- return 'arg=' + req.args.foo;
+ function test_arg(r) {
+ return 'arg=' + r.args.foo;
}
- function test_iarg(req, res) {
+ function test_iarg(r) {
var s = '', a;
- for (a in req.args) {
+ for (a in r.args) {
if (a.substr(0, 3) == 'foo') {
- s += req.args[a];
+ s += r.args[a];
}
}
return s;
}
- function test_var(req, res) {
- return 'variable=' + req.variables.remote_addr;
+ function test_var(r) {
+ return 'variable=' + r.variables.remote_addr;
}
- function test_log(req, res) {
- req.log("SEE-THIS");
+ function test_global(r) {
+ return 'global=' + global;
}
- function test_except(req, res) {
+ function status(r) {
+ r.status = 204;
+ r.sendHeader();
+ r.finish();
+ }
+
+ function ctype(r) {
+ r.status = 200;
+ r.headersOut['Content-Type'] = 'application/foo';
+ r.sendHeader();
+ r.finish();
+ }
+
+ function clen(r) {
+ r.status = 200;
+ r.headersOut['Content-Length'] = 5;
+ r.sendHeader();
+ r.send('foo12');
+ r.finish();
+ }
+
+ function hdr_out(r) {
+ r.status = 200;
+ r.headersOut['Foo'] = r.args.fOO;
+
+ if (r.args.bar) {
+ r.headersOut['Bar'] =
+ r.headersOut[(r.args.bar == 'empty' ? 'Baz' :'Foo')]
+ }
+
+ r.sendHeader();
+ r.finish();
+ }
+
+ function ihdr_out(r) {
+ r.status = 200;
+ r.headersOut['a'] = r.args.a;
+ r.headersOut['b'] = r.args.b;
+
+ var s = '', h;
+ for (h in r.headersOut) {
+ s += r.headersOut[h];
+ }
+
+ r.sendHeader();
+ r.send(s);
+ r.finish();
+ }
+
+ function request_body(r) {
+ try {
+ var body = r.requestBody;
+ r.return(200, body);
+
+ } catch (e) {
+ r.return(500, e.message);
+ }
+ }
+
+ function send(r) {
+ var a, s;
+ r.status = 200;
+ r.sendHeader();
+ for (a in r.args) {
+ if (a.substr(0, 3) == 'foo') {
+ s = r.args[a];
+ r.send('n=' + a + ', v=' + s.substr(0, 2) + ' ');
+ }
+ }
+ r.finish();
+ }
+
+ function return_method(r) {
+ r.return(Number(r.args.c), r.args.t);
+ }
+
+ function return_headers(r) {
+ r.headersOut.Foo = 'bar';
+ r.return(200);
+ }
+
+ function test_log(r) {
+ r.log('SEE-THIS');
+ }
+
+ function test_except(r) {
var fs = require('fs');
fs.readFileSync();
}
- function status(req, res) {
- res.status = 204;
- if (res.status != 204)
- res.status = 404;
- res.sendHeader();
- res.finish();
- }
- function ctype(req, res) {
- res.status = 200;
- res.contentType = 'application/foo';
- res.sendHeader();
- res.finish();
- }
-
- function clen(req, res) {
- res.status = 200;
- res.contentLength = 5;
- if (res.contentLength != 5)
- res.contentLength = 6;
- res.sendHeader();
- res.send('foo12');
- res.finish();
- }
-
- function send(req, res) {
- var a, s;
- res.status = 200;
- res.sendHeader();
- for (a in req.args) {
- if (a.substr(0, 3) == 'foo') {
- s = req.args[a];
- res.send('n=' + a + ', v=' + s.substr(0, 2) + ' ');
- }
- }
- res.finish();
- }
-
- function hdr(req, res) {
- res.status = 200;
- res.headers['Foo'] = req.args.fOO;
-
- if (req.args.bar) {
- res.headers['Bar'] = res.headers['Foo'];
- }
-
- if (req.args.bar == 'empty') {
- res.headers['Bar'] = res.headers['Baz'];
- }
-
- res.sendHeader();
- res.finish();
- }
-
- function ihdr(req, res) {
- res.status = 200;
- res.headers['a'] = req.args.a;
- res.headers['b'] = req.args.b;
-
- var s = '', h;
- for (h in res.headers) {
- s += res.headers[h];
- }
-
- res.sendHeader();
- res.send(s);
- res.finish();
- }
-
- function content_except(req, res) {
+ function content_except(r) {
JSON.parse({}.a.a);
}
- function content_empty(req, res) {
+ function content_empty(r) {
}
EOF
-$t->try_run('no njs available')->plan(23);
+$t->try_run('no njs available')->plan(35);
###############################################################################
-like(http_get('/req_method'), qr/method=GET/, 'req.method');
-like(http_get('/req_version'), qr/version=1.0/, 'req.httpVersion');
-like(http_get('/req_addr'), qr/addr=127.0.0.1/, 'req.remoteAddress');
-like(http_get('/req_uri'), qr/uri=\/req_uri/, 'req.uri');
-like(http_get_hdr('/req_hdr'), qr/hdr=12345/, 'req.headers');
-like(http_get_ihdr('/req_ihdr'), qr/12345barz/, 'req.headers iteration');
-like(http_get('/req_arg?foO=12345'), qr/arg=12345/, 'req.args');
-like(http_get('/req_iarg?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/,
- 'req.args iteration');
-like(http_get('/req_var'), qr/variable=127.0.0.1/, 'req.variables');
-like(http_get('/req_log'), qr/200 OK/, 'req.log');
-
-like(http_get('/res_status'), qr/204 No Content/, 'res.status');
-like(http_get('/res_ctype'), qr/Content-Type: application\/foo/,
- 'res.contentType');
-like(http_get('/res_clen'), qr/Content-Length: 5/, 'res.contentLength');
-like(http_get('/res_send?foo=12345&n=11&foo-2=bar&ndd=&foo-3=z'),
- qr/n=foo, v=12 n=foo-2, v=ba n=foo-3, v=z/, 'res.send');
-like(http_get('/res_hdr?foo=12345'), qr/Foo: 12345/, 'res.headers');
-like(http_get('/res_hdr?foo=123&bar=copy'), qr/Bar: 123/, 'res.headers get');
-like(http_get('/res_hdr?bar=empty'), qr/Bar: \x0d/, 'res.headers empty');
-like(http_get('/res_ihdr?a=12&b=34'), qr/^1234$/m, 'res.headers iteration');
-
-http_get('/req_except');
-http_get('/res_except');
-
-like(http_get('/res_ihdr'), qr/\x0d\x0a?\x0d\x0a?$/m, 'res.send zero');
-
TODO: {
local $TODO = 'not yet'
- unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.1';
-like(http_get('/req_empty'), qr/500 Internal Server Error/, 'empty handler');
+ unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.2';
+
+like(http_get('/method'), qr/method=GET/, 'r.method');
+like(http_get('/version'), qr/version=1.0/, 'r.httpVersion');
+like(http_get('/addr'), qr/addr=127.0.0.1/, 'r.remoteAddress');
+like(http_get('/uri'), qr/uri=\/uri/, 'r.uri');
+like(http_get_hdr('/hdr_in'), qr/hdr=12345/, 'r.headersIn');
+like(http_get_ihdr('/ihdr_in'), qr/12345barz/, 'r.headersIn iteration');
+like(http_get('/arg?foO=12345'), qr/arg=12345/, 'r.args');
+like(http_get('/iarg?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/,
+ 'r.args iteration');
+like(http_get('/status'), qr/204 No Content/, 'r.status');
+like(http_get('/ctype'), qr/Content-Type: application\/foo/,
+ 'r.headersOut.contentType');
+like(http_get('/clen'), qr/Content-Length: 5/, 'r.headersOut.contentLength');
+like(http_get('/hdr_out?foo=12345'), qr/Foo: 12345/, 'r.headersOut');
+like(http_get('/hdr_out?foo=123&bar=copy'), qr/Bar: 123/, 'r.headersOut get');
+like(http_get('/hdr_out?bar=empty'), qr/Bar: \x0d/, 'r.headersOut empty');
+like(http_get('/hdr_out?foo='), qr/Foo: \x0d/, 'r.headersOut no value');
+like(http_get('/hdr_out?foo'), qr/Foo: \x0d/, 'r.headersOut no value 2');
+like(http_get('/ihdr_out?a=12&b=34'), qr/^1234$/m, 'r.headersOut iteration');
+like(http_get('/ihdr_out'), qr/\x0d\x0a?\x0d\x0a?$/m, 'r.send zero');
+
+like(http_post('/body'), qr/REQ-BODY/, 'request body');
+like(http_post('/in_file'), qr/request body is in a file/,
+ 'request body in file');
+like(http_post_big('/body'), qr/200.*^(1234567890){1024}$/ms,
+ 'request body big');
+
+like(http_get('/send?foo=12345&n=11&foo-2=bar&ndd=&foo-3=z'),
+ qr/n=foo, v=12 n=foo-2, v=ba n=foo-3, v=z/, 'r.send');
+
+like(http_get('/return_method?c=200'), qr/200 OK.*\x0d\x0a?\x0d\x0a?$/s,
+ 'return code');
+like(http_get('/return_method?c=200&t=SEE-THIS'), qr/200 OK.*^SEE-THIS$/ms,
+ 'return text');
+like(http_get('/return_method?c=301&t=path'), qr/ 301 .*Location: path/s,
+ 'return redirect');
+like(http_get('/return_method?c=404'), qr/404 Not.*html/s, 'return error page');
+like(http_get('/return_method?c=inv'), qr/ 500 /, 'return invalid');
+
+like(http_get('/return_headers'), qr/Foo: bar/, 'return headers');
+
+like(http_get('/var'), qr/variable=127.0.0.1/, 'r.variables');
+like(http_get('/global'), qr/global=njs/, 'global code');
+like(http_get('/log'), qr/200 OK/, 'r.log');
+
+http_get('/except');
+http_get('/content_except');
+
+like(http_get('/content_empty'), qr/500 Internal Server Error/,
+ 'empty handler');
}
$t->stop();
ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'log js');
ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0,
- 'js_set backtrace');
+ 'js_set backtrace');
ok(index($t->read_file('error.log'), 'at JSON.parse') > 0,
- 'js_content backtrace');
+ 'js_content backtrace');
###############################################################################
@@ -346,4 +416,28 @@
EOF
}
+sub http_post {
+ my ($url, %extra) = @_;
+
+ my $p = "POST $url HTTP/1.0" . CRLF .
+ "Host: localhost" . CRLF .
+ "Content-Length: 8" . CRLF .
+ CRLF .
+ "REQ-BODY";
+
+ return http($p, %extra);
+}
+
+sub http_post_big {
+ my ($url, %extra) = @_;
+
+ my $p = "POST $url HTTP/1.0" . CRLF .
+ "Host: localhost" . CRLF .
+ "Content-Length: 10240" . CRLF .
+ CRLF .
+ ("1234567890" x 1024);
+
+ return http($p, %extra);
+}
+
###############################################################################
diff --git a/js2.t b/js2.t
deleted file mode 100644
index aa35e3f..0000000
--- a/js2.t
+++ /dev/null
@@ -1,443 +0,0 @@
-#!/usr/bin/perl
-
-# (C) Roman Arutyunyan
-# (C) Dmitry Volyntsev
-# (C) Nginx, Inc.
-
-# Tests for http njs module.
-
-###############################################################################
-
-use warnings;
-use strict;
-
-use Test::More;
-use Socket qw/ CRLF /;
-
-BEGIN { use FindBin; chdir($FindBin::Bin); }
-
-use lib 'lib';
-use Test::Nginx;
-
-###############################################################################
-
-select STDERR; $| = 1;
-select STDOUT; $| = 1;
-
-my $t = Test::Nginx->new()->has(qw/http rewrite/)
- ->write_file_expand('nginx.conf', <<'EOF');
-
-%%TEST_GLOBALS%%
-
-daemon off;
-
-events {
-}
-
-http {
- %%TEST_GLOBALS_HTTP%%
-
- js_set $test_method test_method;
- js_set $test_version test_version;
- js_set $test_addr test_addr;
- js_set $test_uri test_uri;
- js_set $test_hdr_in test_hdr_in;
- js_set $test_ihdr_in test_ihdr_in;
- js_set $test_arg test_arg;
- js_set $test_iarg test_iarg;
- js_set $test_var test_var;
- js_set $test_global test_global;
- js_set $test_log test_log;
- js_set $test_except test_except;
-
- js_include test.js;
-
- server {
- listen 127.0.0.1:8080;
- server_name localhost;
-
- location /njs {
- js_content test_njs;
- }
-
- location /method {
- return 200 $test_method;
- }
-
- location /version {
- return 200 $test_version;
- }
-
- location /addr {
- return 200 $test_addr;
- }
-
- location /uri {
- return 200 $test_uri;
- }
-
- location /hdr_in {
- return 200 $test_hdr_in;
- }
-
- location /ihdr_in {
- return 200 $test_ihdr_in;
- }
-
- location /arg {
- return 200 $test_arg;
- }
-
- location /iarg {
- return 200 $test_iarg;
- }
-
- location /var {
- return 200 $test_var;
- }
-
- location /global {
- return 200 $test_global;
- }
-
- location /body {
- js_content request_body;
- }
-
- location /in_file {
- client_body_in_file_only on;
- js_content request_body;
- }
-
- location /status {
- js_content status;
- }
-
- location /ctype {
- js_content ctype;
- }
-
- location /clen {
- js_content clen;
- }
-
- location /hdr_out {
- js_content hdr_out;
- }
-
- location /ihdr_out {
- js_content ihdr_out;
- }
-
- location /request_body {
- js_content request_body;
- }
-
- location /send {
- js_content send;
- }
-
- location /return_method {
- js_content return_method;
- }
-
- location /return_headers {
- js_content return_headers;
- }
-
- location /log {
- return 200 $test_log;
- }
-
- location /except {
- return 200 $test_except;
- }
-
- location /content_except {
- js_content content_except;
- }
-
- location /content_empty {
- js_content content_empty;
- }
- }
-}
-
-EOF
-
-$t->write_file('test.js', <<EOF);
- var global = ['n', 'j', 's'].join("");
-
- function test_njs(r) {
- r.return(200, njs.version);
- }
-
- function test_method(r) {
- return 'method=' + r.method;
- }
-
- function test_version(r) {
- return 'version=' + r.httpVersion;
- }
-
- function test_addr(r) {
- return 'addr=' + r.remoteAddress;
- }
-
- function test_uri(r) {
- return 'uri=' + r.uri;
- }
-
- function test_hdr_in(r) {
- return 'hdr=' + r.headersIn.foo;
- }
-
- function test_ihdr_in(r) {
- var s = '', h;
- for (h in r.headersIn) {
- if (h.substr(0, 3) == 'foo') {
- s += r.headersIn[h];
- }
- }
- return s;
- }
-
- function test_arg(r) {
- return 'arg=' + r.args.foo;
- }
-
- function test_iarg(r) {
- var s = '', a;
- for (a in r.args) {
- if (a.substr(0, 3) == 'foo') {
- s += r.args[a];
- }
- }
- return s;
- }
-
- function test_var(r) {
- return 'variable=' + r.variables.remote_addr;
- }
-
- function test_global(r) {
- return 'global=' + global;
- }
-
- function status(r) {
- r.status = 204;
- r.sendHeader();
- r.finish();
- }
-
- function ctype(r) {
- r.status = 200;
- r.headersOut['Content-Type'] = 'application/foo';
- r.sendHeader();
- r.finish();
- }
-
- function clen(r) {
- r.status = 200;
- r.headersOut['Content-Length'] = 5;
- r.sendHeader();
- r.send('foo12');
- r.finish();
- }
-
- function hdr_out(r) {
- r.status = 200;
- r.headersOut['Foo'] = r.args.fOO;
-
- if (r.args.bar) {
- r.headersOut['Bar'] =
- r.headersOut[(r.args.bar == 'empty' ? 'Baz' :'Foo')]
- }
-
- r.sendHeader();
- r.finish();
- }
-
- function ihdr_out(r) {
- r.status = 200;
- r.headersOut['a'] = r.args.a;
- r.headersOut['b'] = r.args.b;
-
- var s = '', h;
- for (h in r.headersOut) {
- s += r.headersOut[h];
- }
-
- r.sendHeader();
- r.send(s);
- r.finish();
- }
-
- function request_body(r) {
- try {
- var body = r.requestBody;
- r.return(200, body);
-
- } catch (e) {
- r.return(500, e.message);
- }
- }
-
- function send(r) {
- var a, s;
- r.status = 200;
- r.sendHeader();
- for (a in r.args) {
- if (a.substr(0, 3) == 'foo') {
- s = r.args[a];
- r.send('n=' + a + ', v=' + s.substr(0, 2) + ' ');
- }
- }
- r.finish();
- }
-
- function return_method(r) {
- r.return(Number(r.args.c), r.args.t);
- }
-
- function return_headers(r) {
- r.headersOut.Foo = 'bar';
- r.return(200);
- }
-
- function test_log(r) {
- r.log('SEE-THIS');
- }
-
- function test_except(r) {
- var fs = require('fs');
- fs.readFileSync();
- }
-
-
- function content_except(r) {
- JSON.parse({}.a.a);
- }
-
- function content_empty(r) {
- }
-
-EOF
-
-$t->try_run('no njs available')->plan(35);
-
-###############################################################################
-
-TODO: {
-local $TODO = 'not yet'
- unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.2';
-
-like(http_get('/method'), qr/method=GET/, 'r.method');
-like(http_get('/version'), qr/version=1.0/, 'r.httpVersion');
-like(http_get('/addr'), qr/addr=127.0.0.1/, 'r.remoteAddress');
-like(http_get('/uri'), qr/uri=\/uri/, 'r.uri');
-like(http_get_hdr('/hdr_in'), qr/hdr=12345/, 'r.headersIn');
-like(http_get_ihdr('/ihdr_in'), qr/12345barz/, 'r.headersIn iteration');
-like(http_get('/arg?foO=12345'), qr/arg=12345/, 'r.args');
-like(http_get('/iarg?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/,
- 'r.args iteration');
-like(http_get('/status'), qr/204 No Content/, 'r.status');
-like(http_get('/ctype'), qr/Content-Type: application\/foo/,
- 'r.headersOut.contentType');
-like(http_get('/clen'), qr/Content-Length: 5/, 'r.headersOut.contentLength');
-like(http_get('/hdr_out?foo=12345'), qr/Foo: 12345/, 'r.headersOut');
-like(http_get('/hdr_out?foo=123&bar=copy'), qr/Bar: 123/, 'r.headersOut get');
-like(http_get('/hdr_out?bar=empty'), qr/Bar: \x0d/, 'r.headersOut empty');
-like(http_get('/hdr_out?foo='), qr/Foo: \x0d/, 'r.headersOut no value');
-like(http_get('/hdr_out?foo'), qr/Foo: \x0d/, 'r.headersOut no value 2');
-like(http_get('/ihdr_out?a=12&b=34'), qr/^1234$/m, 'r.headersOut iteration');
-like(http_get('/ihdr_out'), qr/\x0d\x0a?\x0d\x0a?$/m, 'r.send zero');
-
-like(http_post('/body'), qr/REQ-BODY/, 'request body');
-like(http_post('/in_file'), qr/request body is in a file/,
- 'request body in file');
-like(http_post_big('/body'), qr/200.*^(1234567890){1024}$/ms,
- 'request body big');
-
-like(http_get('/send?foo=12345&n=11&foo-2=bar&ndd=&foo-3=z'),
- qr/n=foo, v=12 n=foo-2, v=ba n=foo-3, v=z/, 'r.send');
-
-like(http_get('/return_method?c=200'), qr/200 OK.*\x0d\x0a?\x0d\x0a?$/s,
- 'return code');
-like(http_get('/return_method?c=200&t=SEE-THIS'), qr/200 OK.*^SEE-THIS$/ms,
- 'return text');
-like(http_get('/return_method?c=301&t=path'), qr/ 301 .*Location: path/s,
- 'return redirect');
-like(http_get('/return_method?c=404'), qr/404 Not.*html/s, 'return error page');
-like(http_get('/return_method?c=inv'), qr/ 500 /, 'return invalid');
-
-like(http_get('/return_headers'), qr/Foo: bar/, 'return headers');
-
-like(http_get('/var'), qr/variable=127.0.0.1/, 'r.variables');
-like(http_get('/global'), qr/global=njs/, 'global code');
-like(http_get('/log'), qr/200 OK/, 'r.log');
-
-http_get('/except');
-http_get('/content_except');
-
-like(http_get('/content_empty'), qr/500 Internal Server Error/,
- 'empty handler');
-}
-
-$t->stop();
-
-ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'log js');
-ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0,
- 'js_set backtrace');
-ok(index($t->read_file('error.log'), 'at JSON.parse') > 0,
- 'js_content backtrace');
-
-###############################################################################
-
-sub http_get_hdr {
- my ($url, %extra) = @_;
- return http(<<EOF, %extra);
-GET $url HTTP/1.0
-FoO: 12345
-
-EOF
-}
-
-sub http_get_ihdr {
- my ($url, %extra) = @_;
- return http(<<EOF, %extra);
-GET $url HTTP/1.0
-foo: 12345
-Host: localhost
-foo2: bar
-X-xxx: more
-foo-3: z
-
-EOF
-}
-
-sub http_post {
- my ($url, %extra) = @_;
-
- my $p = "POST $url HTTP/1.0" . CRLF .
- "Host: localhost" . CRLF .
- "Content-Length: 8" . CRLF .
- CRLF .
- "REQ-BODY";
-
- return http($p, %extra);
-}
-
-sub http_post_big {
- my ($url, %extra) = @_;
-
- my $p = "POST $url HTTP/1.0" . CRLF .
- "Host: localhost" . CRLF .
- "Content-Length: 10240" . CRLF .
- CRLF .
- ("1234567890" x 1024);
-
- return http($p, %extra);
-}
-
-###############################################################################