comparison proxy_request_buffering_keepalive.t @ 791:2f292082c8a0

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