Mercurial > hg > nginx-tests
annotate h2_proxy_request_buffering_redirect.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 |
---|---|
1498
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with unbuffered request body. |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(1); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
1498
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
41 listen 127.0.0.1:8080; |
1498
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8081; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
45 http2 on; |
1498
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 proxy_http_version 1.1; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location / { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_request_buffering off; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 proxy_pass http://127.0.0.1:8081/bad; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_intercept_errors on; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 error_page 502 = /pass; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 location /bad { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 return 502; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 location /pass { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 proxy_pass http://127.0.0.1:8081/good; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /good { |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 limit_rate 100; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 return 200; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 EOF |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
72 $t->run(); |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1693
diff
changeset
|
73 |
1498
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 ############################################################################### |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 # unbuffered request body |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 my $s = Test::Nginx::HTTP2->new(); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 my $sid = $s->new_stream({ body_more => 1 }); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 $s->h2_body('SEE-', { body_more => 1 }); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 sleep 1; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 $s->h2_body('THIS'); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 is($frame->{headers}->{':status'}, 200, 'discard body rest on redirect'); |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
63a74974a0e9
Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 ############################################################################### |