annotate proxy_pass_request.t @ 1961:fe6f22da53ec default tip

Tests: tests for usage of discarded body. The client_max_body_size limit should be ignored when the request body is already discarded. In HTTP/1.x, this is done by checking the r->discard_body flag when the body is being discarded, and because r->headers_in.content_length_n is 0 when it's already discarded. This, however, does not happen with HTTP/2 and HTTP/3, and therefore "error_page 413" does not work without relaxing the limit. Further, with proxy_pass, r->headers_in.content_length_n is used to determine length of the request body, and therefore is not correct if discarding of the request body isn't yet complete. While discarding the request body, r->headers_in.content_length_n contains the rest of the body to discard (or, in case of chunked request body, the rest of the current chunk to discard). Similarly, the $content_length variable uses r->headers_in.content_length if available, and also incorrect. The $content_length variable is used when proxying with fastcgi_pass, grpc_pass, and uwsgi_pass (scgi_pass uses the value calculated based on the actual request body buffers, and therefore works correctly).
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 27 Apr 2024 18:55:50 +0300
parents 882267679006
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for proxy_pass_request_headers, proxy_pass_request_body directives.
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(3);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 $t->write_file_expand('nginx.conf', <<'EOF');
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 daemon off;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 events {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 http {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
40 listen 127.0.0.1:8080;
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server_name localhost;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 proxy_pass_request_headers off;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 location / {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
46 proxy_pass http://127.0.0.1:8081;
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 location /body {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
50 proxy_pass http://127.0.0.1:8081;
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 proxy_pass_request_headers on;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 proxy_pass_request_body off;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 location /both {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
56 proxy_pass http://127.0.0.1:8081;
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 proxy_pass_request_headers off;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 proxy_pass_request_body off;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 EOF
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 $t->run_daemon(\&http_daemon);
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
66 $t->run()->waitforsocket('127.0.0.1:' . port(8081));
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 ###############################################################################
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 like(get('/', 'foo', 'bar'), qr/Header: none.*Body: bar/s, 'no headers');
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 like(get('/body', 'foo', 'bar'), qr/Header: foo.*Body: none/s, 'no body');
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 like(get('/both', 'foo', 'bar'), qr/Header: none.*Body: none/s, 'both');
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 ###############################################################################
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 sub get {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 my ($uri, $header, $body) = @_;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 my $cl = length("$body\n");
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 http(<<EOF);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 GET $uri HTTP/1.0
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 Host: localhost
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 X-Header: $header
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 Content-Length: $cl
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 $body
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 EOF
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 sub http_daemon {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 my $server = IO::Socket::INET->new(
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 Proto => 'tcp',
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
93 LocalHost => '127.0.0.1:' . port(8081),
893
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 Listen => 5,
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 Reuse => 1
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 )
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 or die "Can't create listening socket: $!\n";
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 local $SIG{PIPE} = 'IGNORE';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 while (my $client = $server->accept()) {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 $client->autoflush(1);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 my $r = '';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106 eval {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 local $SIG{ALRM} = sub { die "timeout\n" };
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 local $SIG{PIPE} = sub { die "sigpipe\n" };
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 alarm(2);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 $client->sysread($r, 4096);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 alarm(0);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 };
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 alarm(0);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 if ($@) {
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 log_in("died: $@");
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 next;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 next if $r eq '';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 Test::Nginx::log_core('|| <<', $r);
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 my $header = $r =~ /x-header: (\S+)/i && $1 || 'none';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 my $body = $r =~ /\x0d\x0a?\x0d\x0a?(.+)/ && $1 || 'none';
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 print $client <<"EOF";
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 HTTP/1.1 200 OK
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 Connection: close
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 X-Header: $header
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 X-Body: $body
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 EOF
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 close $client;
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 }
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137
4fad3232ad56 Tests: proxy_pass_request_headers, proxy_pass_request_body tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 ###############################################################################