Mercurial > hg > nginx-tests
annotate stream_js.t @ 1511:b5620655b506
Tests: HTTP/2 discarded body TODO adjusted, fix committed.
See 8df664ebe037 and 2e61e4b6bcd9 in nginx for details.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 19 Sep 2019 12:18:10 +0300 |
parents | 2e81f7788cf7 |
children | 53ed2231403b |
rev | line source |
---|---|
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
2 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
4 # (C) Dmitry Volyntsev |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
5 # (C) Nginx, Inc. |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
6 |
1375
f168fc46c7a4
Tests: renamed JavaScript to njs.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1374
diff
changeset
|
7 # Tests for stream njs module. |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
8 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
10 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
12 use strict; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
13 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
15 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
17 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx; |
1005
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
20 use Test::Nginx::Stream qw/ dgram stream /; |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
21 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
23 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
26 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy rewrite stream stream_return udp/) |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
29 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
31 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
33 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
34 events { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
35 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
36 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
37 http { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
39 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
40 js_include test.js; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
41 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
42 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
43 listen 127.0.0.1:8079; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
44 server_name localhost; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
45 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
46 location /njs { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
47 js_content test_njs; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
48 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
49 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
50 location /p/ { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
51 proxy_pass http://127.0.0.1:8095/; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
52 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
53 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
54 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
55 location /return { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
56 return 200 $http_foo; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
57 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
58 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
59 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
60 |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
61 stream { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
62 js_set $js_addr js_addr; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
63 js_set $js_var js_var; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
64 js_set $js_log js_log; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 js_set $js_unk js_unk; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
66 js_set $js_req_line js_req_line; |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 js_set $js_sess_unk js_sess_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
68 |
1373 | 69 js_include test.js; |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
70 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
71 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 listen 127.0.0.1:8080; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 return $js_addr; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
74 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 listen 127.0.0.1:8081; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 return $js_log; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
79 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
80 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
81 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
82 listen 127.0.0.1:8082; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 return $js_var; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
84 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 listen 127.0.0.1:8083; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 return $js_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
89 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
90 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
91 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
92 listen 127.0.0.1:8084; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
93 return $js_sess_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
94 } |
1005
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
95 |
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
96 server { |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1005
diff
changeset
|
97 listen 127.0.0.1:%%PORT_8985_UDP%% udp; |
1005
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
98 return $js_addr; |
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
99 } |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
100 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
101 server { |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
102 listen 127.0.0.1:8086; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
103 js_access js_access_step; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
104 js_preread js_preread_step; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
105 js_filter js_filter_step; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
106 proxy_pass 127.0.0.1:8090; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
107 } |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
108 |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
109 server { |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
110 listen 127.0.0.1:8087; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
111 js_access js_access_undecided; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
112 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
113 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
114 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
115 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
116 listen 127.0.0.1:8088; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
117 js_access js_access_allow; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
118 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
119 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
120 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
121 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
122 listen 127.0.0.1:8089; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
123 js_access js_access_deny; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
124 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
125 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
126 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
127 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
128 listen 127.0.0.1:8091; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
129 js_preread js_preread_async; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
130 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
131 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
132 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
133 server { |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
134 listen 127.0.0.1:8092; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
135 js_preread js_preread_data; |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
136 proxy_pass 127.0.0.1:8090; |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
137 } |
1248
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
138 |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
139 server { |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
140 listen 127.0.0.1:8093; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
141 js_preread js_preread_req_line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
142 return $js_req_line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
143 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
144 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
145 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
146 listen 127.0.0.1:8094; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
147 js_filter js_filter_empty; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
148 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
149 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
150 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
151 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
152 listen 127.0.0.1:8095; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
153 js_filter js_filter_header_inject; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
154 proxy_pass 127.0.0.1:8079; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
155 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
156 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
157 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
158 listen 127.0.0.1:8096; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
159 js_filter js_filter_search; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
160 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
161 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
162 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
163 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
164 listen 127.0.0.1:8097; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
165 js_access js_access_except; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
166 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
167 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
168 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
169 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
170 listen 127.0.0.1:8098; |
1248
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
171 js_preread js_preread_except; |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
172 proxy_pass 127.0.0.1:8090; |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
173 } |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
174 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
175 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
176 listen 127.0.0.1:8099; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
177 js_filter js_filter_except; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
178 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
179 } |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
180 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
181 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
182 EOF |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
183 |
1373 | 184 $t->write_file('test.js', <<EOF); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
185 function test_njs(r) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
186 r.return(200, njs.version); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
187 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
188 |
1373 | 189 function js_addr(s) { |
190 return 'addr=' + s.remoteAddress; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
191 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
192 |
1373 | 193 function js_var(s) { |
194 return 'variable=' + s.variables.remote_addr; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
195 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
196 |
1373 | 197 function js_sess_unk(s) { |
198 return 'sess_unk=' + s.unk; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
199 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
200 |
1373 | 201 function js_log(s) { |
202 s.log("SEE-THIS"); | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
203 } |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
204 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
205 var res = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
206 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
207 function js_access_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
208 res += '1'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
209 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
210 setTimeout(function() { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
211 if (s.remoteAddress.match('127.0.0.1')) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
212 s.allow(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
213 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
214 }, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
215 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
216 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
217 function js_preread_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
218 s.on('upload', function (data) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
219 res += '2'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
220 if (res.length >= 3) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
221 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
222 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
223 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
224 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
225 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
226 function js_filter_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
227 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
228 s.send(data); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
229 res += '3'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
230 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
231 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
232 s.on('download', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
233 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
234 if (!flags.last) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
235 res += '4'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
236 s.send(data); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
237 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
238 } else { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
239 res += '5'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
240 s.send(res, {last:1}); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
241 s.off('download'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
242 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
243 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
244 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
245 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
246 function js_access_undecided(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
247 s.decline(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
248 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
249 |
1373 | 250 function js_access_allow(s) { |
251 if (s.remoteAddress.match('127.0.0.1')) { | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
252 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
253 return; |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
254 } |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
255 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
256 s.abort(); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
257 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
258 |
1373 | 259 function js_access_deny(s) { |
260 if (s.remoteAddress.match('127.0.0.1')) { | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
261 s.abort(); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
262 return; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
263 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
264 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
265 s.allow(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
266 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
267 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
268 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
269 function js_preread_async(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
270 setTimeout(function() { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
271 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
272 }, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
273 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
274 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
275 function js_preread_data(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
276 s.on('upload', function (data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
277 if (data.indexOf('z') != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
278 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
279 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
280 }); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
281 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
282 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
283 var line = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
284 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
285 function js_preread_req_line(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
286 s.on('upload', function (data, flags) { |
1441
2e81f7788cf7
Tests: adapted stream_js.t to njs changes.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1375
diff
changeset
|
287 var n = data.indexOf('\\n'); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
288 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
289 line = data.substr(0, n); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
290 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
291 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
292 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
293 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
294 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
295 function js_req_line(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
296 return line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
297 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
298 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
299 function js_filter_empty(s) { |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
300 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
301 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
302 function js_filter_header_inject(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
303 var req = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
304 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
305 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
306 req += data; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
307 |
1441
2e81f7788cf7
Tests: adapted stream_js.t to njs changes.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1375
diff
changeset
|
308 var n = req.search('\\n'); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
309 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
310 var rest = req.substr(n + 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
311 req = req.substr(0, n + 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
312 |
1441
2e81f7788cf7
Tests: adapted stream_js.t to njs changes.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1375
diff
changeset
|
313 s.send(req + 'Foo: foo' + '\\r\\n' + rest, flags); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
314 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
315 s.off('upload'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
316 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
317 }); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
318 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
319 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
320 function js_filter_search(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
321 s.on('download', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
322 var n = data.search('y'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
323 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
324 s.send('z'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
325 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
326 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
327 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
328 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
329 var n = data.search('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
330 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
331 s.send('y'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
332 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
333 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
334 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
335 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
336 function js_access_except(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
337 function done() {return s.a.a}; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
338 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
339 setTimeout(done, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
340 setTimeout(done, 2); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
341 } |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
342 |
1373 | 343 function js_preread_except(s) { |
1248
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
344 var fs = require('fs'); |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
345 fs.readFileSync(); |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
346 } |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
347 |
1373 | 348 function js_filter_except(s) { |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
349 s.on('unknown', function() {}); |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
350 } |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
351 |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
352 EOF |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
353 |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
354 $t->run_daemon(\&stream_daemon, port(8090)); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
355 $t->try_run('no stream njs available')->plan(19); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
356 $t->waitforsocket('127.0.0.1:' . port(8090)); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
357 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
358 ############################################################################### |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
359 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
360 is(stream('127.0.0.1:' . port(8080))->read(), 'addr=127.0.0.1', |
1373 | 361 's.remoteAddress'); |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1005
diff
changeset
|
362 is(dgram('127.0.0.1:' . port(8985))->io('.'), 'addr=127.0.0.1', |
1373 | 363 's.remoteAddress udp'); |
364 is(stream('127.0.0.1:' . port(8081))->read(), 'undefined', 's.log'); | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
365 is(stream('127.0.0.1:' . port(8082))->read(), 'variable=127.0.0.1', |
1373 | 366 's.variables'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
367 is(stream('127.0.0.1:' . port(8083))->read(), '', 'stream js unknown function'); |
1373 | 368 is(stream('127.0.0.1:' . port(8084))->read(), 'sess_unk=undefined', 's.unk'); |
369 | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
370 TODO: { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
371 local $TODO = 'not yet' |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
372 unless get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.4'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
373 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
374 is(stream('127.0.0.1:' . port(8086))->io('0'), '0122345', |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
375 'async handlers order'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
376 is(stream('127.0.0.1:' . port(8087))->io('#'), 'OK', 'js_access_undecided'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
377 is(stream('127.0.0.1:' . port(8088))->io('#'), 'OK', 'js_access_allow'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
378 is(stream('127.0.0.1:' . port(8089))->io('#'), '', 'js_access_deny'); |
1373 | 379 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
380 is(stream('127.0.0.1:' . port(8091))->io('#'), '#', 'js_preread_async'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
381 is(stream('127.0.0.1:' . port(8092))->io('#z'), '#z', 'js_preread_async_data'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
382 is(stream('127.0.0.1:' . port(8093))->io("xy\na"), 'xy', 'js_preread_req_line'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
383 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
384 is(stream('127.0.0.1:' . port(8094))->io('x'), 'x', 'js_filter_empty'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
385 like(get('/p/return'), qr/foo/, 'js_filter_injected_header'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
386 is(stream('127.0.0.1:' . port(8096))->io('x'), 'z', 'js_filter_search'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
387 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
388 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
389 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
390 stream('127.0.0.1:' . port(8097))->io('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
391 stream('127.0.0.1:' . port(8098))->io('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
392 stream('127.0.0.1:' . port(8099))->io('x'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
393 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
394 $t->stop(); |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
395 |
1315
890516ca898a
Tests: reverted 3882f8f3b2bc to unbreak with njs 0.1.15.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1310
diff
changeset
|
396 ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log'); |
1248
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
397 ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
398 'stream js_preread backtrace'); |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
399 ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
400 'stream js_filter backtrace'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
401 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
402 ############################################################################### |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
403 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
404 sub stream_daemon { |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
405 my $server = IO::Socket::INET->new( |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
406 Proto => 'tcp', |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
407 LocalAddr => '127.0.0.1:' . port(8090), |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
408 Listen => 5, |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
409 Reuse => 1 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
410 ) |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
411 or die "Can't create listening socket: $!\n"; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
412 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
413 local $SIG{PIPE} = 'IGNORE'; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
414 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
415 while (my $client = $server->accept()) { |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
416 $client->autoflush(1); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
417 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
418 log2c("(new connection $client)"); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
419 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
420 $client->sysread(my $buffer, 65536) or next; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
421 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
422 log2i("$client $buffer"); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
423 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
424 log2o("$client $buffer"); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
425 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
426 $client->syswrite($buffer); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
427 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
428 close $client; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
429 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
430 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
431 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
432 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
433 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
434 sub log2c { Test::Nginx::log_core('||', @_); } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
435 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
436 sub get { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
437 my ($url, %extra) = @_; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
438 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
439 my $s = IO::Socket::INET->new( |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
440 Proto => 'tcp', |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
441 PeerAddr => '127.0.0.1:' . port(8079) |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
442 ) or die "Can't connect to nginx: $!\n"; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
443 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
444 return http_get($url, socket => $s); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
445 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
446 |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
447 ############################################################################### |