Mercurial > hg > nginx-tests
annotate h2_request_body_extra.t @ 1999:15f538440a77 default tip
Tests: adjusted proxy_cache_use_stale.t cache validity.
At least the "s-w-r - updating stale" test sometimes fails on slow
hosts due to "stale-while-revalidate=4" being not enough, so the request
returns with the EXPIRED cache status instead of STALE.
Fix is to use larger "stale-while-revalidate=" times where it is not
significant.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 09 Aug 2024 18:37:25 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
1726
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with request body, additional tests. |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 ############################################################################### |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use warnings; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 use strict; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Test::More; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 ############################################################################### |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 daemon off; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
41 listen 127.0.0.1:8080; |
1726
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 listen 127.0.0.1:8081; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 server_name localhost; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1937
diff
changeset
|
45 http2 on; |
1726
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 client_header_buffer_size 1k; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 client_body_buffer_size 2k; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 location / { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 add_header X-Body $request_body; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 add_header X-Body-File $request_body_file; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 proxy_pass http://127.0.0.1:8082; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 location /file { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 client_body_in_file_only on; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 add_header X-Body "$request_body"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 add_header X-Body-File "$request_body_file"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 proxy_pass http://127.0.0.1:8082; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 location /single { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 client_body_in_single_buffer on; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 add_header X-Body "$request_body"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 add_header X-Body-File "$request_body_file"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 proxy_pass http://127.0.0.1:8082; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 location /large { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 client_max_body_size 1k; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 proxy_pass http://127.0.0.1:8082; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 location /unbuf/ { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 add_header X-Unbuf-File "$request_body_file"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 proxy_pass http://127.0.0.1:8081/; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 proxy_request_buffering off; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 proxy_http_version 1.1; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 server { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 listen 127.0.0.1:8082; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 server_name localhost; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 return 204; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 EOF |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 $t->plan(50); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 $t->run(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 ############################################################################### |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 # below are basic body tests from body.t, slightly |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 # adapted to HTTP/2, repeated multiple times with variations: |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 # |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 # buffered vs. non-buffered, length vs. chunked, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 # single frame vs. multiple frames |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 # |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 # some does not make sense in HTTP/2 (such as "body in two buffers"), but |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 # preserved for consistency and due to the fact that proxying via HTTP/1.1 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 # is used in unbuffered tests |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 unlike(http2_get('/'), qr/x-body:/ms, 'no body'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 like(http2_get_body('/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 qr/x-body: 0123456789$/ms, 'body'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 like(http2_get_body('/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 qr/x-body: (0123456789){128}$/ms, 'body in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 like(http2_get_body('/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 qr/x-body-file/ms, 'body in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 like(read_body_file(http2_get_body('/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 qr/^(0123456789){512}$/s, 'body in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 like(http2_get_body('/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 qr/x-body: (0123456789){128}$/ms, 'body in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 like(http2_get_body('/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 qr/:status: 413/, 'body too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 # without Content-Length header |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 like(http2_get_body_nolen('/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 qr/x-body: 0123456789$/ms, 'body nolen'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 like(http2_get_body_nolen('/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 qr/x-body: (0123456789){128}$/ms, 'body nolen in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 like(http2_get_body_nolen('/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 qr/x-body-file/ms, 'body nolen in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 like(read_body_file(http2_get_body_nolen('/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 qr/^(0123456789){512}$/s, 'body nolen in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 like(http2_get_body_nolen('/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 qr/x-body: (0123456789){128}$/ms, 'body nolen in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 like(http2_get_body_nolen('/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 qr/:status: 413/, 'body nolen too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 # with multiple frames |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 like(http2_get_body_multi('/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 qr/x-body: 0123456789$/ms, 'body multi'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 like(http2_get_body_multi('/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 qr/x-body: (0123456789){128}$/ms, 'body multi in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 like(http2_get_body_multi('/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 qr/x-body-file/ms, 'body multi in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 like(read_body_file(http2_get_body_multi('/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 qr/^(0123456789){512}$/s, 'body multi in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 like(http2_get_body_multi('/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 qr/x-body: (0123456789){128}$/ms, 'body multi in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 like(http2_get_body_multi('/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 qr/:status: 413/, 'body multi too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 # with multiple frames and without Content-Length header |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 like(http2_get_body_multi_nolen('/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 qr/x-body: 0123456789$/ms, 'body multi nolen'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 like(http2_get_body_multi_nolen('/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 qr/x-body: (0123456789){128}/ms, 'body multi nolen in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 like(http2_get_body_multi_nolen('/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 qr/x-body-file/ms, 'body multi nolen in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 like(read_body_file(http2_get_body_multi_nolen('/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 qr/^(0123456789){512}$/s, 'body multi nolen in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 like(http2_get_body_multi_nolen('/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 qr/x-body: (0123456789){128}$/ms, 'body multi nolen in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 like(http2_get_body_multi_nolen('/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 qr/:status: 413/, 'body multi nolen too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 # unbuffered |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 unlike(http2_get('/unbuf/'), qr/x-body:/ms, 'no body unbuf'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 like(http2_get_body('/unbuf/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 qr/x-body: 0123456789$/ms, 'body unbuf'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 like(http2_get_body('/unbuf/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 qr/x-body: (0123456789){128}$/ms, 'body unbuf in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 like(http2_get_body('/unbuf/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 qr/(?!.*x-unbuf-file.*)x-body-file/ms, 'body unbuf in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 like(read_body_file(http2_get_body('/unbuf/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 qr/^(0123456789){512}$/s, 'body unbuf in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 like(http2_get_body('/unbuf/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 qr/x-body: (0123456789){128}$/ms, 'body unbuf in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 like(http2_get_body('/unbuf/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 qr/:status: 413/, 'body unbuf too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 # unbuffered without Content-Length |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 like(http2_get_body_nolen('/unbuf/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 qr/x-body: 0123456789$/ms, 'body unbuf nolen'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 like(http2_get_body_nolen('/unbuf/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 qr/x-body: (0123456789){128}$/ms, 'body unbuf nolen in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 like(http2_get_body_nolen('/unbuf/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 qr/(?!.*x-unbuf-file.*)x-body-file/ms, 'body unbuf nolen in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 like(read_body_file(http2_get_body_nolen('/unbuf/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 qr/^(0123456789){512}$/s, 'body unbuf nolen in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 like(http2_get_body_nolen('/unbuf/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 qr/x-body: (0123456789){128}$/ms, 'body unbuf nolen in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 like(http2_get_body_nolen('/unbuf/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 qr/:status: 413/, 'body unbuf nolen too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 # unbuffered with multiple frames |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 like(http2_get_body_multi('/unbuf/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 qr/x-body: 0123456789$/ms, 'body unbuf multi'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 like(http2_get_body_multi('/unbuf/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
203 qr/x-body: (0123456789){128}$/ms, 'body unbuf multi in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 like(http2_get_body_multi('/unbuf/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 qr/(?!.*x-unbuf-file.*)x-body-file/ms, 'body unbuf multi in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 like(read_body_file(http2_get_body_multi('/unbuf/file', '0123456789' x 512)), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 qr/^(0123456789){512}$/s, 'body unbuf multi in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 like(http2_get_body_multi('/unbuf/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 qr/x-body: (0123456789){128}$/ms, 'body unbuf multi in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 like(http2_get_body_multi('/unbuf/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 qr/:status: 413/, 'body unbuf multi too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 # unbuffered with multiple frames and without Content-Length |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 like(http2_get_body_multi_nolen('/unbuf/', '0123456789'), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 qr/x-body: 0123456789$/ms, 'body unbuf multi nolen'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 like(http2_get_body_multi_nolen('/unbuf/', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 qr/x-body: (0123456789){128}$/ms, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 'body unbuf multi nolen in two buffers'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 like(http2_get_body_multi_nolen('/unbuf/', '0123456789' x 512), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 qr/(?!.*x-unbuf-file.*)x-body-file/ms, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 'body unbuf multi nolen in file'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 like(read_body_file(http2_get_body_multi_nolen('/unbuf/file', |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 '0123456789' x 512)), qr/^(0123456789){512}$/s, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 'body unbuf multi nolen in file only'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 like(http2_get_body_multi_nolen('/unbuf/single', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 qr/x-body: (0123456789){128}$/ms, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 'body unbuf multi nolen in single buffer'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 like(http2_get_body_multi_nolen('/unbuf/large', '0123456789' x 128), |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 qr/:status: 413/, 'body unbuf multi nolen too large'); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 ############################################################################### |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 sub http2_get { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 my ($uri) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 my $s = Test::Nginx::HTTP2->new(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 my $sid = $s->new_stream({ path => $uri }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 keys %{$frame->{headers}}); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 sub http2_get_body { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 my ($uri, $body) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 my $s = Test::Nginx::HTTP2->new(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 my $sid = $s->new_stream({ path => $uri, body => $body }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 keys %{$frame->{headers}}); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 sub http2_get_body_nolen { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 my ($uri, $body) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 my $s = Test::Nginx::HTTP2->new(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 my $sid = $s->new_stream({ path => $uri, body_more => 1 }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 $s->h2_body($body); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 keys %{$frame->{headers}}); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 sub http2_get_body_multi { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 my ($uri, $body) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 my $s = Test::Nginx::HTTP2->new(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 my $sid = $s->new_stream({ |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 headers => [ |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 { name => ':method', value => 'GET' }, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 { name => ':scheme', value => 'http' }, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 { name => ':path', value => $uri }, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
283 { name => ':authority', value => 'localhost' }, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 { name => 'content-length', value => length $body }, |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 ], |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 body_more => 1 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 for my $b (split //, $body, 10) { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 $s->h2_body($b, { body_more => 1 }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 select undef, undef, undef, 0.1; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 $s->h2_body(''); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 keys %{$frame->{headers}}); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
301 sub http2_get_body_multi_nolen { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
302 my ($uri, $body) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 my $s = Test::Nginx::HTTP2->new(); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 my $sid = $s->new_stream({ path => $uri, body_more => 1 }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 for my $b (split //, $body, 10) { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 $s->h2_body($b, { body_more => 1 }); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 select undef, undef, undef, 0.1; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 $s->h2_body(''); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 return join("\n", map { "$_: " . $frame->{headers}->{$_}; } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 keys %{$frame->{headers}}); |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 sub read_body_file { |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 my ($r) = @_; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 return '' unless $r =~ m/x-body-file: (.*)/; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 open FILE, $1 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 or return "$!"; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 local $/; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 my $content = <FILE>; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 close FILE; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 return $content; |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 } |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 |
f66266cc82c8
Tests: additional HTTP/2 request body tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 ############################################################################### |