Mercurial > hg > nginx-tests
annotate stream_js.t @ 1619:436d0ffc2ea3
Tests: correctly shutdown ssl for reproducible session reuse tests.
Previously, session reuse tests in stream_ssl_certificate.t were prone
to testing errors, since the client doesn't write any application data
before closing a connection, which is done so to pass tests on win32.
In this case, the server may happened to get an unexpected eof meaning
that it will abandon that session. This is specific to stream testing
pattern, changes to ssl_certificate.t are applied too for consistency.
This is also specific to SSL_R_UNEXPECTED_EOF_WHILE_READING, which is
implemented in OpenSSL 3.0.0.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 23 Nov 2020 22:46:06 +0000 |
parents | f3ba4c74de31 |
children | cd35d4f44937 |
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 { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1544
diff
changeset
|
62 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1544
diff
changeset
|
63 |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
64 js_set $js_addr js_addr; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 js_set $js_var js_var; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
66 js_set $js_log js_log; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 js_set $js_unk js_unk; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
68 js_set $js_req_line js_req_line; |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
69 js_set $js_sess_unk js_sess_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
70 |
1373 | 71 js_include test.js; |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
74 listen 127.0.0.1:8080; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 return $js_addr; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
79 listen 127.0.0.1:8081; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
80 return $js_log; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
81 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
82 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
84 listen 127.0.0.1:8082; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 return $js_var; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
89 listen 127.0.0.1:8083; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
90 return $js_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
91 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
92 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
93 server { |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
94 listen 127.0.0.1:8084; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
95 return $js_sess_unk; |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
96 } |
1005
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
97 |
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
98 server { |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1005
diff
changeset
|
99 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
|
100 return $js_addr; |
557faa1782e5
Tests: stream JavaScript test with udp.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1003
diff
changeset
|
101 } |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
102 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
103 server { |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 } |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
110 |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
111 server { |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
112 listen 127.0.0.1:8087; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
113 js_access js_access_undecided; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
114 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
115 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
116 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
117 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
118 listen 127.0.0.1:8088; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
119 js_access js_access_allow; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
120 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
121 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
122 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
123 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
124 listen 127.0.0.1:8089; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
125 js_access js_access_deny; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
126 return OK; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
127 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
128 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
129 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
130 listen 127.0.0.1:8091; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
131 js_preread js_preread_async; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
132 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
133 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
134 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
135 server { |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
136 listen 127.0.0.1:8092; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
137 js_preread js_preread_data; |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
138 proxy_pass 127.0.0.1:8090; |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
139 } |
1248
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
140 |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
141 server { |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
142 listen 127.0.0.1:8093; |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
143 js_preread js_preread_req_line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
144 return $js_req_line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
145 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
146 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
147 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
148 listen 127.0.0.1:8094; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
149 js_filter js_filter_empty; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
150 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
151 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
152 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
153 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
154 listen 127.0.0.1:8095; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
155 js_filter js_filter_header_inject; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
156 proxy_pass 127.0.0.1:8079; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
157 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
158 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
159 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
160 listen 127.0.0.1:8096; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
161 js_filter js_filter_search; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
162 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
163 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
164 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
165 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
166 listen 127.0.0.1:8097; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
167 js_access js_access_except; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
168 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
169 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
170 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
171 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 } |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
176 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
177 server { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
178 listen 127.0.0.1:8099; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
179 js_filter js_filter_except; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
180 proxy_pass 127.0.0.1:8090; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
181 } |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
182 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
183 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
184 EOF |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
185 |
1373 | 186 $t->write_file('test.js', <<EOF); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
187 function test_njs(r) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
188 r.return(200, njs.version); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
189 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
190 |
1373 | 191 function js_addr(s) { |
192 return 'addr=' + s.remoteAddress; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
193 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
194 |
1373 | 195 function js_var(s) { |
196 return 'variable=' + s.variables.remote_addr; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
197 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
198 |
1373 | 199 function js_sess_unk(s) { |
200 return 'sess_unk=' + s.unk; | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
201 } |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
202 |
1373 | 203 function js_log(s) { |
204 s.log("SEE-THIS"); | |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
205 } |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
206 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
207 var res = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
208 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
209 function js_access_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
210 res += '1'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
211 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
212 setTimeout(function() { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
213 if (s.remoteAddress.match('127.0.0.1')) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
214 s.allow(); |
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 }, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
217 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
218 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
219 function js_preread_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
220 s.on('upload', function (data) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
221 res += '2'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
222 if (res.length >= 3) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
223 s.done(); |
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 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
227 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
228 function js_filter_step(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
229 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
230 s.send(data); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
231 res += '3'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
232 }); |
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 s.on('download', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
235 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
236 if (!flags.last) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
237 res += '4'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
238 s.send(data); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
239 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
240 } else { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
241 res += '5'; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
242 s.send(res, {last:1}); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
243 s.off('download'); |
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 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
247 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
248 function js_access_undecided(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
249 s.decline(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
250 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
251 |
1373 | 252 function js_access_allow(s) { |
253 if (s.remoteAddress.match('127.0.0.1')) { | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
254 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
255 return; |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
256 } |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
257 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
258 s.abort(); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
259 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
260 |
1373 | 261 function js_access_deny(s) { |
262 if (s.remoteAddress.match('127.0.0.1')) { | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
263 s.abort(); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
264 return; |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
265 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
266 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
267 s.allow(); |
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 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
270 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
271 function js_preread_async(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
272 setTimeout(function() { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
273 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
274 }, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
275 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
276 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
277 function js_preread_data(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
278 s.on('upload', function (data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
279 if (data.indexOf('z') != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
280 s.done(); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
281 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
282 }); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
283 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
284 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
285 var line = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
286 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
287 function js_preread_req_line(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
288 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
|
289 var n = data.indexOf('\\n'); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
290 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
291 line = data.substr(0, n); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
292 s.done(); |
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 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
296 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
297 function js_req_line(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
298 return line; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
299 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
300 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
301 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
|
302 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
303 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
304 function js_filter_header_inject(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
305 var req = ''; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
306 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
307 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
308 req += data; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
309 |
1441
2e81f7788cf7
Tests: adapted stream_js.t to njs changes.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1375
diff
changeset
|
310 var n = req.search('\\n'); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
311 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
312 var rest = req.substr(n + 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
313 req = req.substr(0, n + 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
314 |
1441
2e81f7788cf7
Tests: adapted stream_js.t to njs changes.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1375
diff
changeset
|
315 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
|
316 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
317 s.off('upload'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
318 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
319 }); |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
320 } |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
321 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
322 function js_filter_search(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
323 s.on('download', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
324 var n = data.search('y'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
325 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
326 s.send('z'); |
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 }); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
329 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
330 s.on('upload', function(data, flags) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
331 var n = data.search('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
332 if (n != -1) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
333 s.send('y'); |
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 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
337 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
338 function js_access_except(s) { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
339 function done() {return s.a.a}; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
340 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
341 setTimeout(done, 1); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
342 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
|
343 } |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
344 |
1373 | 345 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
|
346 var fs = require('fs'); |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
347 fs.readFileSync(); |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
348 } |
70192b1baf01
Tests: added exception test to stream_js.t using 'require'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1247
diff
changeset
|
349 |
1373 | 350 function js_filter_except(s) { |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
351 s.on('unknown', function() {}); |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
352 } |
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
353 |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
354 EOF |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
355 |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
356 $t->run_daemon(\&stream_daemon, port(8090)); |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
357 $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
|
358 $t->waitforsocket('127.0.0.1:' . port(8090)); |
1003
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 ############################################################################### |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
361 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
362 is(stream('127.0.0.1:' . port(8080))->read(), 'addr=127.0.0.1', |
1373 | 363 's.remoteAddress'); |
1237
e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1005
diff
changeset
|
364 is(dgram('127.0.0.1:' . port(8985))->io('.'), 'addr=127.0.0.1', |
1373 | 365 's.remoteAddress udp'); |
366 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
|
367 is(stream('127.0.0.1:' . port(8082))->read(), 'variable=127.0.0.1', |
1373 | 368 's.variables'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
369 is(stream('127.0.0.1:' . port(8083))->read(), '', 'stream js unknown function'); |
1373 | 370 is(stream('127.0.0.1:' . port(8084))->read(), 'sess_unk=undefined', 's.unk'); |
371 | |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
372 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
|
373 'async handlers order'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
374 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
|
375 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
|
376 is(stream('127.0.0.1:' . port(8089))->io('#'), '', 'js_access_deny'); |
1373 | 377 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
378 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
|
379 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
|
380 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
|
381 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
386 stream('127.0.0.1:' . port(8097))->io('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
387 stream('127.0.0.1:' . port(8098))->io('x'); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
388 stream('127.0.0.1:' . port(8099))->io('x'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
389 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
390 $t->stop(); |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
391 |
1315
890516ca898a
Tests: reverted 3882f8f3b2bc to unbreak with njs 0.1.15.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1310
diff
changeset
|
392 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
|
393 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
|
394 'stream js_preread backtrace'); |
1247
edf5a3c9e36a
Tests: added tests for js backtraces.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1239
diff
changeset
|
395 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
|
396 'stream js_filter backtrace'); |
1003
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
397 |
a86034bcbe82
Tests: stream JavaScript tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
398 ############################################################################### |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
399 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
400 sub stream_daemon { |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
401 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
|
402 Proto => 'tcp', |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
403 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
|
404 Listen => 5, |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
405 Reuse => 1 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
406 ) |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
407 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
|
408 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
409 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
|
410 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
411 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
|
412 $client->autoflush(1); |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
413 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
414 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
|
415 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
416 $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
|
417 |
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
418 log2i("$client $buffer"); |
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 log2o("$client $buffer"); |
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 $client->syswrite($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 close $client; |
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 } |
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 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
|
429 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
|
430 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
|
431 |
1374
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
432 sub get { |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
433 my ($url, %extra) = @_; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
434 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
435 my $s = IO::Socket::INET->new( |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
436 Proto => 'tcp', |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
437 PeerAddr => '127.0.0.1:' . port(8079) |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
438 ) or die "Can't connect to nginx: $!\n"; |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
439 |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
440 return http_get($url, socket => $s); |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
441 } |
fd7766ab0a69
Tests: stream njs module refactored.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
1373
diff
changeset
|
442 |
1239
4a825ec85c8d
Tests: added tests for js_access, js_preread, and js_filter.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1237
diff
changeset
|
443 ############################################################################### |