Mercurial > hg > nginx-tests
comparison js_request_body.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 | bc0990ea2e5b |
children | 386748f328b1 |
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_include test.js; | 40 js_import test.js; |
41 | 41 |
42 server { | 42 server { |
43 listen 127.0.0.1:8080; | 43 listen 127.0.0.1:8080; |
44 server_name localhost; | 44 server_name localhost; |
45 | 45 |
46 location /body { | 46 location /body { |
47 js_content test_body; | 47 js_content test.body; |
48 } | 48 } |
49 | 49 |
50 location /in_file { | 50 location /in_file { |
51 client_body_in_file_only on; | 51 client_body_in_file_only on; |
52 js_content test_body; | 52 js_content test.body; |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 EOF | 57 EOF |
58 | 58 |
59 $t->write_file('test.js', <<EOF); | 59 $t->write_file('test.js', <<EOF); |
60 function test_body(r) { | 60 function body(r) { |
61 try { | 61 try { |
62 var body = r.requestBody; | 62 var body = r.requestBody; |
63 r.return(200, body); | 63 r.return(200, body); |
64 | 64 |
65 } catch (e) { | 65 } catch (e) { |
66 r.return(500, e.message); | 66 r.return(500, e.message); |
67 } | 67 } |
68 } | 68 } |
69 | |
70 export default {body}; | |
69 | 71 |
70 EOF | 72 EOF |
71 | 73 |
72 $t->try_run('no njs request body')->plan(3); | 74 $t->try_run('no njs request body')->plan(3); |
73 | 75 |