Mercurial > hg > nginx-tests
annotate h2_proxy_request_buffering_ssl.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 to ssl 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 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_ssl http_v2 proxy/) |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1519
diff
changeset
|
29 ->has_daemon('openssl')->plan(40); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 $t->write_file_expand('nginx.conf', <<'EOF'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
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 events { |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 http { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
44 listen 127.0.0.1:8080; |
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 https://127.0.0.1:8082; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 client_body_buffer_size 512; |
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 https://127.0.0.1:8082; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 client_body_buffer_size 512; |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
63 listen 127.0.0.1:8082 ssl; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 server_name localhost; |
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 ssl_certificate_key localhost.key; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 ssl_certificate localhost.crt; |
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 location / { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 proxy_request_buffering off; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
71 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
|
72 client_body_buffer_size 1k; |
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 location /chunked { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 proxy_request_buffering off; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 proxy_http_version 1.1; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 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
|
78 client_body_buffer_size 1k; |
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 } |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 $t->write_file('openssl.conf', <<EOF); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1421
diff
changeset
|
87 default_bits = 2048 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 encrypt_key = no |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 distinguished_name = req_distinguished_name |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 [ req_distinguished_name ] |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $d = $t->testdir(); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 foreach my $name ('localhost') { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
97 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
98 . "-out $d/$name.crt -keyout $d/$name.key " |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 . ">>$d/openssl.out 2>&1") == 0 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 or die "Can't create certificate for $name: $!\n"; |
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 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $t->run(); |
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 ############################################################################### |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 # unbuffered request body |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
109 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
|
110 ok($f->{headers}, 'request'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 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
|
112 is($f->{upload}('56789'), '56789', 'part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 is($f->{http_end}(), 200, 'response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 $f = get_body('/', 'content-length' => 1536); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 ok($f->{headers}, 'buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 is($f->{http_end}(), 200, 'buffer - 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 $f = get_body('/', 'content-length' => 18); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 ok($f->{headers}, 'many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 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
|
125 '01234many', 'many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 '56789many', 'many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 is($f->{http_end}(), 200, 'many - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 $f = get_body('/', 'content-length' => 0); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 ok($f->{headers}, 'empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
903
diff
changeset
|
132 is($f->{upload}('', body_more => 1, wait => 0.2), '', 'empty - part'); |
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
903
diff
changeset
|
133 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
|
134 is($f->{http_end}(), 200, 'empty - 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('/', 'content-length' => 10); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 ok($f->{headers}, 'split'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 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
|
139 is($f->{http_end}(), 200, 'split - response'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 # unbuffered request body, chunked transfer-encoding |
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}, 'chunk'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 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
|
146 'chunked - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 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
|
148 'chunked - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 is($f->{http_end}(), 200, 'chunked - response'); |
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 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 ok($f->{headers}, 'chunked buffer'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 is($f->{upload}('0123' x 64, body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 '100' . CRLF . '0123' x 64 . CRLF, 'chunked buffer - below'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 is($f->{upload}('4567' x 64, body_more => 1), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 '100' . CRLF . '4567' x 64 . CRLF, 'chunked buffer - equal'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 is($f->{upload}('89AB' x 64), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 '100' . CRLF . '89AB' x 64 . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 'chunked buffer - above'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 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
|
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 many'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 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
|
165 '9' . CRLF . '01234many' . CRLF, 'chunked many - part'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 is($f->{upload}('56789many', body_split => [ 5 ]), |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 '9' . CRLF . '56789many' . CRLF . '0' . CRLF . CRLF, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 'chunked many - part 2'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 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
|
170 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 ok($f->{headers}, 'chunked empty'); |
945
d73bef563aea
Tests: speed up HTTP/2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
903
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 $f = get_body('/chunked'); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 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
|
179 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
|
180 '0123456789', 'chunked split'); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 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
|
182 |
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 |
1271
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
185 sub http_content { |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
186 my ($body) = @_; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
187 my $content = ''; |
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 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
|
190 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
|
191 $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
|
192 pos($body) += $len; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
193 } |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
194 |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
195 return $content; |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
196 } |
6ca8b38f63b6
Tests: relaxed proxy_request_buffering tests to pass on slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
197 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 sub get_body { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 my ($url, %extra) = @_; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 my ($server, $client, $f); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 $server = IO::Socket::INET->new( |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 Proto => 'tcp', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 LocalHost => '127.0.0.1', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
205 LocalPort => port(8081), |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 Listen => 5, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 Timeout => 3, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 Reuse => 1 |
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 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
|
211 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
212 my $s = Test::Nginx::HTTP2->new(); |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 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
|
214 ? $s->new_stream({ headers => [ |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 { name => ':method', value => 'GET' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 { name => ':scheme', value => 'http' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 { name => ':path', value => $url, }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 { name => ':authority', value => 'localhost' }, |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 { name => 'content-length', |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 value => $extra{'content-length'} }], |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 body_more => 1 }) |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
222 : $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
|
223 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 $client = $server->accept() or return; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 log2c("(new connection $client)"); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
228 $f->{headers} = backend_read($client); |
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 my $chunked = $f->{headers} =~ /chunked/; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
232 $f->{upload} = sub { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
233 my ($body, %extra) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
234 my $len = length($body); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
235 my $wait = $extra{wait}; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
236 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
237 $s->h2_body($body, { %extra }); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
238 |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
239 $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 for (1 .. 10) { |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
242 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
|
243 $body .= $buf; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 my $got = 0; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 $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
|
247 ? $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
|
248 : length($body); |
1519
787d904bdfe0
Tests: fixed reading chunked body in HTTP/2 unbuffered body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
249 next if $chunked && !$extra{body_more} |
787d904bdfe0
Tests: fixed reading chunked body in HTTP/2 unbuffered body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1488
diff
changeset
|
250 && $buf !~ /^0\x0d\x0a?/m; |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 last if $got >= $len; |
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 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
254 return $body; |
879
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 $f->{http_end} = sub { |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 $client->write(<<EOF); |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 HTTP/1.1 200 OK |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 Connection: close |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 EOF |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 $client->close; |
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 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
|
266 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 return $frame->{headers}->{':status'}; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 }; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 return $f; |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 |
948
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
272 sub backend_read { |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
273 my ($s, $timo) = @_; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
274 my $buf = ''; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
275 |
1421
4e48bf51714f
Tests: aligned various generic read timeouts to http_end().
Sergey Kandaurov <pluknet@nginx.com>
parents:
1420
diff
changeset
|
276 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
|
277 $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
|
278 log2i($buf); |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
279 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
280 return $buf; |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
281 } |
4dc302d8e04f
Tests: changed HTTP2 package to act as a class.
Sergey Kandaurov <pluknet@nginx.com>
parents:
945
diff
changeset
|
282 |
879
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
283 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
284 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
285 sub log2c { Test::Nginx::log_core('||', @_); } |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
286 |
127a602f36c8
Tests: HTTP/2 tests for unbuffered request body.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
287 ############################################################################### |