# HG changeset patch # User Sergey Kandaurov # Date 1469452837 -10800 # Node ID 3ee5ca1ec728f259586cee7bb918ea5ca1314763 # Parent 1beb641e21c972a3dc192d9c7683bd651e31b752 Tests: updated js.t to the new http js module syntax. diff --git a/js.t b/js.t --- a/js.t +++ b/js.t @@ -34,28 +34,16 @@ events { http { %%TEST_GLOBALS_HTTP%% - js_set $test_method "'method=' + $r.method"; - js_set $test_version "'version=' + $r.httpVersion"; - js_set $test_addr "'addr=' + $r.remoteAddress"; - js_set $test_uri "'uri=' + $r.uri"; - js_set $test_hdr "'hdr=' + $r.headers.foo"; - js_set $test_ihdr "var s; - s = ''; - for (h in $r.headers) { - if (h.substr(0, 3) == 'foo') { - s += $r.headers[h]; - } - } - s;"; - js_set $test_arg "'arg=' + $r.args.foo"; - js_set $test_iarg "var s; - s = ''; - for (a in $r.args) { - if (a.substr(0, 3) == 'foo') { - s += $r.args[a]; - } - } - s;"; + 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_include test.js; server { listen 127.0.0.1:8080; @@ -94,69 +82,118 @@ http { } location /res_status { - js_run " - var res; - res = $r.response; - res.status = 204; - res.sendHeader(); - res.finish(); - "; + js_content status; } location /res_ctype { - js_run " - var res; - res = $r.response; - res.status = 200; - res.contentType = 'application/foo'; - res.sendHeader(); - res.finish(); - "; + js_content ctype; } location /res_clen { - js_run " - var res; - res = $r.response; - res.status = 200; - res.contentLength = 5; - res.sendHeader(); - res.send('foo12'); - res.finish(); - "; + js_content clen; } location /res_send { - js_run " - var res, a, s; - res = $r.response; - res.status = 200; - res.sendHeader(); - for (a in $r.args) { - if (a.substr(0, 3) == 'foo') { - s = $r.args[a]; - res.send('n=' + a + ', v=' + s.substr(0, 2) + ' '); - } - } - res.finish(); - "; + js_content send; } location /res_hdr { - js_run " - var res; - res = $r.response; - res.status = 200; - res.headers['Foo'] = $r.args.fOO; - res.sendHeader(); - res.finish(); - "; + js_content hdr; } } } EOF +$t->write_file('test.js', <try_run('no njs available')->plan(13); ###############################################################################