Mercurial > hg > nginx-tests
annotate h2_proxy_request_buffering.t @ 1238:e35cc79ed4a1
Tests: show try_run() errors in verbose mode.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 14 Nov 2017 15:34:18 +0300 |
parents | d0523391deb9 |
children | 766bcbb632ee |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/); |
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 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 listen 127.0.0.1:8080 http2; |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 proxy_request_buffering off; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 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
|
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 location /chunked { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 proxy_request_buffering off; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_http_version 1.1; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
55 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
|
56 client_body_buffer_size 1k; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
58 location /abort { |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 } |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
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 EOF |
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 $t->run(); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
903
29aa547dd963
Tests: avoided potential hang in HTTP/2 unbuf request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
879
diff
changeset
|
70 my $f = get_body('/chunked'); |
29aa547dd963
Tests: avoided potential hang in HTTP/2 unbuf request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
879
diff
changeset
|
71 plan(skip_all => 'no unbuffered request body') unless $f; |
29aa547dd963
Tests: avoided potential hang in HTTP/2 unbuf request body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
879
diff
changeset
|
72 $f->{http_end}(); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
74 $t->plan(49); |
879
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 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 # unbuffered request body |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 ok($f->{headers}, 'request'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 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
|
83 is($f->{upload}('56789'), '56789', 'part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 is($f->{http_end}(), 200, 'response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 ok($f->{headers}, 'much'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 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
|
89 is($f->{upload}('many'), '', 'much - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 is($f->{http_end}(), 400, 'much - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 ok($f->{headers}, 'less'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 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
|
95 is($f->{upload}('56789'), '', 'less - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 is($f->{http_end}(), 400, 'less - response'); |
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' => 18); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 ok($f->{headers}, 'many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 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
|
101 '01234many', 'many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 '56789many', 'many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 is($f->{http_end}(), 200, 'many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 $f = get_body('/', 'content-length' => 0); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 ok($f->{headers}, 'empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
938
diff
changeset
|
108 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
|
109 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
|
110 is($f->{http_end}(), 200, 'empty - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 $f = get_body('/', 'content-length' => 1536); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 ok($f->{headers}, 'buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 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
|
115 'buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 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
|
117 'buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 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
|
119 is($f->{http_end}(), 200, 'buffer - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 $f = get_body('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 ok($f->{headers}, 'split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 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
|
124 is($f->{http_end}(), 200, 'split - 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 # unbuffered request body, chunked transfer-encoding |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 ok($f->{headers}, 'chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 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
|
131 'chunked - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 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
|
133 'chunked - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 is($f->{http_end}(), 200, 'chunked - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 ok($f->{headers}, 'chunked buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 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
|
139 '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
|
140 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
|
141 '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
|
142 is($f->{upload}('89AB' x 128), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 '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
|
144 'chunked buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 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
|
146 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 ok($f->{headers}, 'chunked many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 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
|
150 '9' . CRLF . '01234many' . CRLF, 'chunked many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 '9' . CRLF . '56789many' . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 'chunked many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 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
|
155 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 ok($f->{headers}, 'chunked empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
938
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 ok($f->{headers}, 'chunked split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 is($f->{upload}('0123456789', split => [ 14 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 '5' . CRLF . '01234' . CRLF . '5' . CRLF . '56789' . CRLF . |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 '0' . CRLF . CRLF, 'chunked split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 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
|
168 |
983
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
169 # 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
|
170 # 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
|
171 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
172 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
|
173 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
|
174 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
175 $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
|
176 $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
|
177 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
178 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
|
179 |
daf3fb13a80d
Tests: HTTP/2 test for unbuf request body aborted on partial DATA.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
180 $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
|
181 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
|
182 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 sub get_body { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 my ($url, %extra) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 my ($server, $client, $f); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 $server = IO::Socket::INET->new( |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 Proto => 'tcp', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 LocalHost => '127.0.0.1', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
192 LocalPort => port(8081), |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 Listen => 5, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 Timeout => 3, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 Reuse => 1 |
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 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
|
198 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
199 my $s = Test::Nginx::HTTP2->new(); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 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
|
201 ? $s->new_stream({ headers => [ |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 { name => ':method', value => 'GET' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 { name => ':scheme', value => 'http' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 { name => ':path', value => $url, }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 { name => ':authority', value => 'localhost' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 { name => 'content-length', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 value => $extra{'content-length'} }], |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 body_more => 1 }) |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
209 : $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
|
210 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 $client = $server->accept() or return; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 log2c("(new connection $client)"); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
215 $f->{headers} = backend_read($client); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 my $chunked = $f->{headers} =~ /chunked/; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
219 $f->{upload} = sub { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
220 my ($body, %extra) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
221 my $len = length($body); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
222 my $wait = $extra{wait}; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
223 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
224 $s->h2_body($body, { %extra }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
225 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
226 $body = ''; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 for (1 .. 10) { |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
229 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
|
230 $body .= $buf; |
879
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 my $got = 0; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 $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
|
234 ? $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
|
235 : length($body); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 last if $got >= $len; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
239 return $body; |
879
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 $f->{http_end} = sub { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 $client->write(<<EOF); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 HTTP/1.1 200 OK |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 Connection: close |
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 EOF |
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 $client->close; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
250 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
|
251 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 return $frame->{headers}->{':status'}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 }; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 return $f; |
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 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
257 sub backend_read { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
258 my ($s, $timo) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
259 my $buf = ''; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
260 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
261 if (IO::Select->new($s)->can_read($timo || 3)) { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
262 $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
|
263 log2i($buf); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
264 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
265 return $buf; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
266 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
267 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 sub log2c { Test::Nginx::log_core('||', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 ############################################################################### |