Mercurial > hg > nginx-tests
annotate h2_fastcgi_request_buffering.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with unbuffered request body and fastcgi backend. |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
19 use Test::Nginx::HTTP2; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 fastcgi/)->plan(48); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
41 listen 127.0.0.1:8080; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server_name localhost; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
44 http2 on; |
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
45 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 location / { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 fastcgi_request_buffering off; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 fastcgi_pass 127.0.0.1:8081; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 fastcgi_param REQUEST_URI $request_uri; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 client_body_buffer_size 1k; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 $t->run(); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 # unbuffered request body to fastcgi |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
63 my $f = get_body('/'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 ok($f->{headers}, 'request'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 is($f->{upload}('01234', body_more => 1), '01234', 'part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 is($f->{upload}('56789'), '56789_eos', 'part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 is($f->{http_end}(), 200, 'response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 $f = get_body('/'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 ok($f->{headers}, 'buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 is($f->{upload}('0123' x 128, body_more => 1), '0123' x 128, 'buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 is($f->{upload}('4567' x 128, body_more => 1), '4567' x 128, 'buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 is($f->{upload}('89AB' x 128), '89AB' x 128 . '_eos', 'buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 is($f->{http_end}(), 200, 'buffer - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 $f = get_body('/'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 ok($f->{headers}, 'many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 is($f->{upload}('01234many', body_split => [ 5 ], body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 '01234many', 'many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 '56789many_eos', 'many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 is($f->{http_end}(), 200, 'many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 $f = get_body('/'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 ok($f->{headers}, 'empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
925
diff
changeset
|
86 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'empty - part'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 is($f->{upload}(''), '_eos', 'empty - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 is($f->{http_end}(), 200, 'empty - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 $f = get_body('/'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 ok($f->{headers}, 'split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 is($f->{upload}('0123456789', split => [ 14 ]), '0123456789_eos', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 'split - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 is($f->{http_end}(), 200, 'split - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 # unbuffered request body to fastcgi, content-length |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 ok($f->{headers}, 'cl'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 is($f->{upload}('01234', body_more => 1), '01234', 'cl - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 is($f->{upload}('56789'), '56789_eos', 'cl - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 is($f->{http_end}(), 200, 'cl - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $f = get_body('/', 'content-length' => 1536); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 ok($f->{headers}, 'cl buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 is($f->{upload}('0123' x 128, body_more => 1), '0123' x 128, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 'cl buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 is($f->{upload}('4567' x 128, body_more => 1), '4567' x 128, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 'cl buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 is($f->{upload}('89AB' x 128), '89AB' x 128 . '_eos', 'cl buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 is($f->{http_end}(), 200, 'cl buffer - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ok($f->{headers}, 'cl much'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 is($f->{upload}('0123456789', body_more => 1), '0123456789', 'cl much - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 is($f->{upload}('many'), '', 'cl much - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 is($f->{http_end}(), 400, 'cl much - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 ok($f->{headers}, 'cl less'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 is($f->{upload}('0123', body_more => 1), '0123', 'cl less - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 is($f->{upload}('56789'), '', 'cl less - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 is($f->{http_end}(), 400, 'cl less - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $f = get_body('/', 'content-length' => 18); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 ok($f->{headers}, 'cl many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 is($f->{upload}('01234many', body_split => [ 5 ], body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 '01234many', 'cl many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 is($f->{upload}('56789many', body_split => [ 5 ]), '56789many_eos', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 'cl many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 is($f->{http_end}(), 200, 'cl many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 $f = get_body('/', 'content-length' => 0); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 ok($f->{headers}, 'cl empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
925
diff
changeset
|
136 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'cl empty - part'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 is($f->{upload}(''), '_eos', 'cl empty - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 is($f->{http_end}(), 200, 'cl empty - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 ok($f->{headers}, 'cl split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 is($f->{upload}('0123456789', split => [ 14 ]), '0123456789_eos', 'cl split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 is($f->{http_end}(), 200, 'cl split - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 # Simple FastCGI responder implementation. |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 # http://www.fastcgi.com/devkit/doc/fcgi-spec.html |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 sub fastcgi_read_record($) { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 my ($buf) = @_; |
925
6bb1f2ccd386
Tests: removed unused variables.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
903
diff
changeset
|
153 my $h; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 return undef unless length $$buf; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 @{$h}{qw/ version type id clen plen /} = unpack("CCnnC", $$buf); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 $h->{content} = substr $$buf, 8, $h->{clen}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 $h->{padding} = substr $$buf, 8 + $h->{clen}, $h->{plen}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 $$buf = substr $$buf, 8 + $h->{clen} + $h->{plen}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 return $h; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 sub fastcgi_respond($$$$) { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 my ($socket, $version, $id, $body) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 # stdout |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 $socket->write(pack("CCnnCx", $version, 6, $id, length($body), 0)); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 $socket->write($body); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 # close stdout |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 $socket->write(pack("CCnnCx", $version, 6, $id, 0, 0)); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 # end request |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 $socket->write(pack("CCnnCx", $version, 3, $id, 8, 0)); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 $socket->write(pack("NCxxx", 0, 0)); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 sub get_body { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 my ($url, %extra) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 my ($server, $client, $f); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 $server = IO::Socket::INET->new( |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 Proto => 'tcp', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 LocalHost => '127.0.0.1', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
189 LocalPort => port(8081), |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 Listen => 5, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 Timeout => 3, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 Reuse => 1 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 ) |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 or die "Can't create listening socket: $!\n"; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
196 my $s = Test::Nginx::HTTP2->new(); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 my $sid = exists $extra{'content-length'} |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
198 ? $s->new_stream({ headers => [ |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 { name => ':method', value => 'GET' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 { name => ':scheme', value => 'http' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 { name => ':path', value => $url, }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 { name => ':authority', value => 'localhost' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 { name => 'content-length', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 value => $extra{'content-length'} }], |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 body_more => 1 }) |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
206 : $s->new_stream({ path => $url, body_more => 1 }); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 $client = $server->accept() or return; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 log2c("(new connection $client)"); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
212 $f->{headers} = backend_read($client); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 my $h = fastcgi_read_record(\$f->{headers}); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 my $version = $h->{version}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 my $id = $h->{id}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 $f->{upload} = sub { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 my ($body, %extra) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 my $len = length($body); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
925
diff
changeset
|
221 my $wait = $extra{wait}; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
223 $s->h2_body($body, { %extra }); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 $body = ''; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 for (1 .. 10) { |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
228 my $buf = backend_read($client, $wait) or return ''; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 while (my $h = fastcgi_read_record(\$buf)) { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 # skip everything unless stdin |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 next if $h->{type} != 5; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 $body .= $h->{content}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 # mark the end-of-stream indication |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 $body .= "_eos" if $h->{clen} == 0; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 last if length($body) >= $len; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 return $body; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 }; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 $f->{http_end} = sub { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 local $SIG{PIPE} = 'IGNORE'; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 fastcgi_respond($client, $version, $id, <<EOF); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 Status: 200 OK |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 Connection: close |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 OK |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
256 $client->close; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
258 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 return $frame->{headers}->{':status'}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 }; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 return $f; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
264 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
265 sub backend_read { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
266 my ($s, $timo) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
267 my $buf = ''; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
268 |
1421
4e48bf51714f
Tests: aligned various generic read timeouts to http_end().
Sergey Kandaurov <pluknet@nginx.com>
parents:
1420
diff
changeset
|
269 if (IO::Select->new($s)->can_read($timo || 8)) { |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
270 $s->sysread($buf, 16384) or return; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
271 log2i($buf); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
272 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
273 return $buf; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
274 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
275 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
277 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 sub log2c { Test::Nginx::log_core('||', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 ############################################################################### |