Mercurial > hg > nginx-tests
annotate h2_proxy_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. |
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 use Socket qw/ CRLF /; |
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 BEGIN { use FindBin; chdir($FindBin::Bin); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
21 use Test::Nginx::HTTP2; |
879
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 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1519
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(49); |
879
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 $t->write_file_expand('nginx.conf', <<'EOF'); |
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 %%TEST_GLOBALS%% |
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 daemon off; |
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 events { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 http { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 %%TEST_GLOBALS_HTTP%% |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
43 listen 127.0.0.1:8080; |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
44 listen 127.0.0.1:8082; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
47 http2 on; |
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
48 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 proxy_request_buffering off; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
51 proxy_pass http://127.0.0.1:8081/; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 client_body_buffer_size 1k; |
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 location /chunked { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 proxy_request_buffering off; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 proxy_http_version 1.1; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
57 proxy_pass http://127.0.0.1:8081/; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 client_body_buffer_size 1k; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
60 location /abort { |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
61 proxy_request_buffering off; |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
62 proxy_http_version 1.1; |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
63 proxy_pass http://127.0.0.1:8082/; |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
64 } |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $t->run(); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 # unbuffered request body |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1083
diff
changeset
|
76 my $f = get_body('/', 'content-length' => 10); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 ok($f->{headers}, 'request'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 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
|
79 is($f->{upload}('56789'), '56789', 'part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 is($f->{http_end}(), 200, 'response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ok($f->{headers}, 'much'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 is($f->{upload}('0123456789', body_more => 1), '0123456789', 'much - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 is($f->{upload}('many'), '', 'much - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 is($f->{http_end}(), 400, 'much - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 ok($f->{headers}, 'less'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 is($f->{upload}('0123', body_more => 1), '0123', 'less - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 is($f->{upload}('56789'), '', 'less - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 is($f->{http_end}(), 400, 'less - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 $f = get_body('/', 'content-length' => 18); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 ok($f->{headers}, 'many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 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
|
97 '01234many', 'many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 '56789many', 'many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 is($f->{http_end}(), 200, 'many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 $f = get_body('/', 'content-length' => 0); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 ok($f->{headers}, 'empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
938
diff
changeset
|
104 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'empty - part'); |
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
938
diff
changeset
|
105 is($f->{upload}('', wait => 0.2), '', 'empty - part 2'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 is($f->{http_end}(), 200, 'empty - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 $f = get_body('/', 'content-length' => 1536); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 ok($f->{headers}, 'buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 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
|
111 'buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 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
|
113 'buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 is($f->{upload}('89AB' x 128), '89AB' x 128, 'buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 is($f->{http_end}(), 200, 'buffer - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 ok($f->{headers}, 'split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 is($f->{upload}('0123456789', split => [ 14 ]), '0123456789', 'split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 is($f->{http_end}(), 200, 'split - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 # unbuffered request body, chunked transfer-encoding |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 ok($f->{headers}, 'chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 is($f->{upload}('01234', body_more => 1), '5' . CRLF . '01234' . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 'chunked - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 is($f->{upload}('56789'), '5' . CRLF . '56789' . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 'chunked - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 is($f->{http_end}(), 200, 'chunked - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 ok($f->{headers}, 'chunked buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 is($f->{upload}('0123' x 128, body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 '200' . CRLF . '0123' x 128 . CRLF, 'chunked buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 is($f->{upload}('4567' x 128, body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 '200' . CRLF . '4567' x 128 . CRLF, 'chunked buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 is($f->{upload}('89AB' x 128), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 '200' . CRLF . '89AB' x 128 . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 'chunked buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 is($f->{http_end}(), 200, 'chunked buffer - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 ok($f->{headers}, 'chunked many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 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
|
146 '9' . CRLF . '01234many' . CRLF, 'chunked many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 '9' . CRLF . '56789many' . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 'chunked many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 is($f->{http_end}(), 200, 'chunked many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ok($f->{headers}, 'chunked empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
938
diff
changeset
|
154 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'chunked empty - part'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 is($f->{upload}(''), '0' . CRLF . CRLF, 'chunked empty - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 is($f->{http_end}(), 200, 'chunked empty - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 ok($f->{headers}, 'chunked split'); |
1271
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
160 is(http_content($f->{upload}('0123456789', split => [ 14 ])), |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
161 '0123456789', 'chunked split'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 is($f->{http_end}(), 200, 'chunked split - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
164 # unbuffered request body, chunked transfer-encoding |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
165 # client sends partial DATA frame and closes connection |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
166 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
167 my $s = Test::Nginx::HTTP2->new(); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
168 my $s2 = Test::Nginx::HTTP2->new(); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
169 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
170 $s->new_stream({ path => '/abort', body_more => 1 }); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
171 $s->h2_body('TEST', { split => [ 9 ], abort => 1 }); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
172 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
173 close $s->{socket}; |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
174 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
175 $s2->h2_ping('PING'); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
176 isnt(@{$s2->read()}, 0, 'chunked abort'); |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
177 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 |
1271
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
180 sub http_content { |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
181 my ($body) = @_; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
182 my $content = ''; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
183 |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
184 while ($body =~ /\G\x0d?\x0a?([0-9a-f]+)\x0d\x0a?/gcmsi) { |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
185 my $len = hex($1); |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
186 $content .= substr($body, pos($body), $len); |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
187 pos($body) += $len; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
188 } |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
189 |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
190 return $content; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
191 } |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
192 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 sub get_body { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 my ($url, %extra) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 my ($server, $client, $f); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 $server = IO::Socket::INET->new( |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 Proto => 'tcp', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 LocalHost => '127.0.0.1', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
200 LocalPort => port(8081), |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 Listen => 5, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 Timeout => 3, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 Reuse => 1 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 ) |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 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
|
206 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
207 my $s = Test::Nginx::HTTP2->new(); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 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
|
209 ? $s->new_stream({ headers => [ |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 { name => ':method', value => 'GET' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 { name => ':scheme', value => 'http' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 { name => ':path', value => $url, }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 { name => ':authority', value => 'localhost' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 { name => 'content-length', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 value => $extra{'content-length'} }], |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 body_more => 1 }) |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
217 : $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
|
218 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 $client = $server->accept() or return; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 log2c("(new connection $client)"); |
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 $f->{headers} = backend_read($client); |
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 my $chunked = $f->{headers} =~ /chunked/; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
227 $f->{upload} = sub { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
228 my ($body, %extra) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
229 my $len = length($body); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
230 my $wait = $extra{wait}; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
231 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
232 $s->h2_body($body, { %extra }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
233 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
234 $body = ''; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 for (1 .. 10) { |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
237 my $buf = backend_read($client, $wait) or return ''; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
238 $body .= $buf; |
879
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 my $got = 0; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 $got += $chunked ? hex $_ : $_ for $chunked |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
242 ? $body =~ /(\w+)\x0d\x0a?\w+\x0d\x0a?/g |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
243 : length($body); |
1519
787d904bdfe0
Tests: fixed reading chunked body in HTTP/2 unbuffered body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
244 next if $chunked && !$extra{body_more} |
787d904bdfe0
Tests: fixed reading chunked body in HTTP/2 unbuffered body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
245 && $buf !~ /^0\x0d\x0a?/m; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 last if $got >= $len; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
249 return $body; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 }; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 $f->{http_end} = sub { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 $client->write(<<EOF); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 HTTP/1.1 200 OK |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 Connection: close |
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 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 $client->close; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
260 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
|
261 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 return $frame->{headers}->{':status'}; |
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 return $f; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
265 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
266 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
267 sub backend_read { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
268 my ($s, $timo) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
269 my $buf = ''; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
270 |
1421
4e48bf51714f
Tests: aligned various generic read timeouts to http_end().
Sergey Kandaurov <pluknet@nginx.com>
parents:
1420
diff
changeset
|
271 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
|
272 $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
|
273 log2i($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 return $buf; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
276 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
277 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 sub log2c { Test::Nginx::log_core('||', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 ############################################################################### |