Mercurial > hg > nginx-tests
annotate h2_request_body_preread.t @ 1896:8b74936ff2ac
Tests: added has_feature() test for CryptX.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 29 May 2023 17:04:36 +0400 |
parents | c9d7e2a26b2d |
children | 236d038dc04a |
rev | line source |
---|---|
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with preread request body. |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy limit_req/); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
1459
2710e9505937
Tests: adjusted limit_req rate in HTTP/2 body preread tests more.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1070
diff
changeset
|
40 limit_req_zone $binary_remote_addr zone=req:1m rate=20r/m; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
43 listen 127.0.0.1:8080 http2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
44 listen 127.0.0.1:8081; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 http2_body_preread_size 10; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location /t { } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 location / { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 add_header X-Body $request_body; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
52 proxy_pass http://127.0.0.1:8081/t; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /req { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 limit_req zone=req burst=2; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
56 proxy_pass http://127.0.0.1:8081/t; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
62 listen 127.0.0.1:8082 http2; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server_name localhost; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 http2_body_preread_size 0; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 location / { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 add_header X-Body $request_body; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
69 proxy_pass http://127.0.0.1:8081/t; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 location /req { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 limit_req zone=req burst=2; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
73 proxy_pass http://127.0.0.1:8081/t; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
79 listen 127.0.0.1:8083 http2; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 server_name localhost; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 location / { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 add_header X-Body $request_body; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
84 proxy_pass http://127.0.0.1:8081/t; |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 EOF |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 $t->write_file('t', ''); |
1499
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
92 $t->run()->plan(9); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 ############################################################################### |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 # request body within preread size (that is, stream window) |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 my $s = Test::Nginx::HTTP2->new(); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 my $sid = $s->new_stream({ body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 is($frame->{headers}->{'x-body'}, 'TEST', 'within preread'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 # request body beyond preread size |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 # RST_STREAM expected due stream window violation |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 TODO: { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 local $TODO = 'not yet'; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 $s = Test::Nginx::HTTP2->new(); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 $sid = $s->new_stream({ body => 'TEST' x 10 }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 $frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 is($frame->{code}, 3, 'beyond preread - FLOW_CONTROL_ERROR'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 # within preread size - limited |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 $s = Test::Nginx::HTTP2->new(); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 $sid = $s->new_stream({ path => '/req' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $sid = $s->new_stream({ path => '/req', body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 is($frame->{headers}->{'x-body'}, 'TEST', 'within preread limited'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
1499
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
132 # processing request body without END_STREAM in preread |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
133 |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
134 $sid = $s->new_stream({ path => '/req', body_more => 1, continuation => 1 }); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
135 $s->h2_continue($sid, |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
136 { headers => [{ name => 'content-length', value => '8' }]}); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
137 |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
138 $s->h2_body('SEE', { body_more => 1 }); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
139 $s->read(all => [{ type => 'WINDOW_UPDATE' }]); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
140 |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
141 $s->h2_body('-THIS'); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
142 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
143 |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
144 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
145 is($frame->{headers}->{'x-body'}, 'SEE-THIS', 'within preread limited - more'); |
c9d7e2a26b2d
Tests: HTTP/2 request body preread of DATA without END_STREAM.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1459
diff
changeset
|
146 |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 # beyond preread size - limited |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 $s = Test::Nginx::HTTP2->new(); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 $sid = $s->new_stream({ path => '/req', body => 'TEST' x 10 }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 is($frame->{code}, 3, 'beyond preread limited - FLOW_CONTROL_ERROR'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 # zero preread size |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 TODO: { |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 local $TODO = 'not yet'; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
162 $s = Test::Nginx::HTTP2->new(port(8082)); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 $sid = $s->new_stream({ body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 $frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 is($frame->{code}, 3, 'zero preread - FLOW_CONTROL_ERROR'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 } |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 # zero preread size - limited |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
173 $s = Test::Nginx::HTTP2->new(port(8082)); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 $sid = $s->new_stream({ path => '/req', body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 is($frame->{code}, 3, 'zero preread limited - FLOW_CONTROL_ERROR'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 # REFUSED_STREAM on request body prior SETTINGS acknowledgement |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
183 $s = Test::Nginx::HTTP2->new(port(8080), pure => 1); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 $sid = $s->new_stream({ body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 is($frame->{code}, 7, 'no SETTINGS ack - REFUSED_STREAM'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 # default preread size - no REFUSED_STREAM expected |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
962
diff
changeset
|
192 $s = Test::Nginx::HTTP2->new(port(8083), pure => 1); |
954
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 $sid = $s->new_stream({ body => 'TEST' }); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 is($frame->{headers}->{'x-body'}, 'TEST', 'no SETTINGS ack - default preread'); |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 |
b9692ec5a08b
Tests: HTTP/2 request body preread tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 ############################################################################### |