Mercurial > hg > nginx-tests
annotate fastcgi_body.t @ 1282:fd281e3a3df5
Tests: better test names in h2_server_push.t.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 12 Feb 2018 14:46:40 +0300 |
parents | 196d33c2bb45 |
children |
rev | line source |
---|---|
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Test for fastcgi backend with chunked request body. |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(5) |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
242
diff
changeset
|
29 daemon off; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 events { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 http { |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
38 listen 127.0.0.1:8080; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 server_name localhost; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
42 fastcgi_pass 127.0.0.1:8081; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 fastcgi_param REQUEST_URI $request_uri; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 fastcgi_param CONTENT_LENGTH $content_length; |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 $t->run_daemon(\&fastcgi_daemon); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
52 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
56 like(http_get('/'), qr/X-Body: _eos\x0d?$/ms, 'fastcgi no body'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
58 like(http_get_length('/', ''), qr/X-Body: _eos\x0d?$/ms, 'fastcgi empty body'); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
59 like(http_get_length('/', 'foobar'), qr/X-Body: foobar_eos\x0d?$/ms, |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
60 'fastcgi body'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
62 like(http(<<EOF), qr/X-Body: foobar_eos\x0d?$/ms, 'fastcgi chunked'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 GET / HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 Transfer-Encoding: chunked |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 6 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 foobar |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 0 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
74 like(http(<<EOF), qr/X-Body: _eos\x0d?$/ms, 'fastcgi empty chunked'); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 GET / HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 Transfer-Encoding: chunked |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 0 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 sub http_get_length { |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
317
diff
changeset
|
87 my ($url, $body) = @_; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 my $length = length $body; |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
317
diff
changeset
|
89 return http(<<EOF); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 GET $url HTTP/1.1 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 Host: localhost |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 Connection: close |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 Content-Length: $length |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 $body |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 ############################################################################### |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
101 # Simple FastCGI responder implementation. |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
102 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
103 # http://www.fastcgi.com/devkit/doc/fcgi-spec.html |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
104 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
105 sub fastcgi_read_record($) { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
106 my ($buf) = @_; |
925
6bb1f2ccd386
Tests: removed unused variables.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
898
diff
changeset
|
107 my $h; |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
108 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
109 return undef unless length $$buf; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
110 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
111 @{$h}{qw/ version type id clen plen /} = unpack("CCnnC", $$buf); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
112 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
113 $h->{content} = substr $$buf, 8, $h->{clen}; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
114 $h->{padding} = substr $$buf, 8 + $h->{clen}, $h->{plen}; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
115 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
116 $$buf = substr $$buf, 8 + $h->{clen} + $h->{plen}; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
117 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
118 return $h; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
119 } |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
120 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
121 sub fastcgi_respond($$$$) { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
122 my ($socket, $version, $id, $body) = @_; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
123 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
124 # stdout |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
125 $socket->write(pack("CCnnCx", $version, 6, $id, length($body), 0)); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
126 $socket->write($body); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
127 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
128 # close stdout |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
129 $socket->write(pack("CCnnCx", $version, 6, $id, 0, 0)); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
130 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
131 # end request |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
132 $socket->write(pack("CCnnCx", $version, 3, $id, 8, 0)); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
133 $socket->write(pack("NCxxx", 0, 0)); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
134 } |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
136 sub fastcgi_daemon { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
137 my $server = IO::Socket::INET->new( |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
138 Proto => 'tcp', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
139 LocalAddr => '127.0.0.1:' . port(8081), |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
140 Listen => 5, |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
141 Reuse => 1 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
142 ) |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
143 or die "Can't create listening socket: $!\n"; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
144 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
145 local $SIG{PIPE} = 'IGNORE'; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
146 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
147 while (my $client = $server->accept()) { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
148 $client->autoflush(1); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
149 Test::Nginx::log_core('||', "fastcgi connection"); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
150 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
151 $client->sysread(my $buf, 1024) or next; |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
153 my ($version, $id); |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
154 my $body = ''; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
155 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
156 while (my $h = fastcgi_read_record(\$buf)) { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
157 $version = $h->{version}; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
158 $id = $h->{id}; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
159 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
160 Test::Nginx::log_core('||', "fastcgi record: " |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
161 . " $h->{version}, $h->{type}, $h->{id}, " |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
162 . "'$h->{content}'"); |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 |
895
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
164 if ($h->{type} == 5) { |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
165 $body .= $h->{content} if $h->{clen} > 0; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
166 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
167 # count stdin end-of-stream |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
168 $body .= '_eos' if $h->{clen} == 0; |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
169 } |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
170 } |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
171 |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
172 # respond |
894e142ebdf8
Tests: TODO fastcgi request body end-of-stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
173 fastcgi_respond($client, $version, $id, <<EOF); |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
925
diff
changeset
|
174 Location: http://localhost/redirect |
240
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 Content-Type: text/html |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 X-Body: $body |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 SEE-THIS |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 EOF |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 } |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
462d89f5732a
Tests: request body and chunked transfer encoding tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 ############################################################################### |