Mercurial > hg > nginx-tests
annotate proxy_request_buffering_keepalive.t @ 955:b8948aecba12
Tests: HTTP/2 request body Content-Length tests in proxied request.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Jun 2016 20:46:10 +0300 |
parents | e9064d691790 |
children | 882267679006 |
rev | line source |
---|---|
791
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for unbuffered request body and proxy with keepalive. |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy upstream_keepalive/)->plan(1); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 upstream backend { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
810
diff
changeset
|
40 server 127.0.0.1:%%PORT_1%%; |
791
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 keepalive 1; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
810
diff
changeset
|
45 listen 127.0.0.1:%%PORT_0%%; |
791
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server_name localhost; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 proxy_http_version 1.1; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_set_header Connection ""; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location / { |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 proxy_pass http://backend; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 add_header X-Body $request_body; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_request_buffering off; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 server { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
810
diff
changeset
|
59 listen 127.0.0.1:%%PORT_1%%; |
791
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 server_name localhost; |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 location / { } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 EOF |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 $t->write_file('t1', 'SEE-THIS'); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 $t->run(); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 ############################################################################### |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 # We emulate an early upstream server response while proxy is still |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 # transmitting the request body. In this case, the request body is |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 # discarded by proxy, and 2nd request will be processed by upstream |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 # as remain request body. |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 http(<<EOF); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 GET /t1 HTTP/1.0 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 Host: localhost |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 Content-Length: 10 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 EOF |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 TODO: { |
810
a4f806eb4426
Tests: proxy_request_buffering_keepalive.t TODO adjusted.
Sergey Kandaurov <pluknet@nginx.com>
parents:
791
diff
changeset
|
86 local $TODO = 'not yet' unless $t->has_version('1.9.10'); |
791
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 like(http_get('/t1'), qr/200 OK.*SEE/ms, 'keepalive after discarded'); |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
2f292082c8a0
Tests: upstream keepalive tests with request body (ticket #669).
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 ############################################################################### |