Mercurial > hg > nginx-tests
annotate proxy_merge_headers.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 5ad8f0b5fa0f |
children |
rev | line source |
---|---|
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for proxy_set_header inheritance. |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
13 use Socket qw/ CRLF /; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ############################################################################### |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(11) |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
241
diff
changeset
|
30 daemon off; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 events { |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 http { |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
249
diff
changeset
|
39 keys_zone=NAME:1m; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 proxy_set_header X-Blah "blah"; |
228
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
42 proxy_hide_header X-Hidden; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 listen 127.0.0.1:8080; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 server_name localhost; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 proxy_cache NAME; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
51 proxy_pass http://127.0.0.1:8081; |
228
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
52 |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
53 location /nested/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
54 proxy_pass http://127.0.0.1:8081; |
228
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
55 proxy_pass_header X-Pad; |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
56 } |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 location /no/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
60 proxy_pass http://127.0.0.1:8081; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 proxy_cache off; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 location /setbody/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
65 proxy_pass http://127.0.0.1:8081; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 proxy_set_body "body"; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 } |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
68 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
69 location /passdate/ { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
70 proxy_pass http://127.0.0.1:8082; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
71 proxy_pass_header Date; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
72 proxy_pass_header Server; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
73 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
74 location /passdate/no/ { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
75 proxy_pass http://127.0.0.1:8082; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
76 } |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
77 } |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
81 listen 127.0.0.1:8081; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 server_name localhost; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 location / { |
228
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
85 add_header X-Hidden "hidden"; |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
86 add_header X-Pad "passed"; |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 return 200 "ims=$http_if_modified_since;blah=$http_x_blah;"; |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 EOF |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
94 $t->run_daemon(\&http_daemon); |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 $t->run(); |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
97 $t->waitforsocket('127.0.0.1:' . port(8082)); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
98 |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 ############################################################################### |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 like(http_get_ims('/'), qr/ims=;blah=blah;/, |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 'if-modified-since cleared with cache'); |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 like(http_get_ims('/no/'), qr/ims=blah;blah=blah;/, |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 'if-modified-since preserved without cache'); |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 like(http_get_ims('/setbody/'), qr/blah=blah;/, |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 'proxy_set_header inherited with proxy_set_body'); |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 |
228
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
110 unlike(http_get('/'), qr/X-Pad/, 'proxy_pass_header default'); |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
111 like(http_get('/nested/'), qr/X-Pad/, 'proxy_pass_header nested'); |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
112 unlike(http_get('/'), qr/X-Hidden/, 'proxy_hide_header inherited'); |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
113 unlike(http_get('/nested/'), qr/X-Hidden/, 'proxy_hide_header nested'); |
5c9e43547b71
Tests: proxy_hide_header/proxy_pass_header inheritance tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
114 |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
115 like(http_get('/passdate/'), qr/Date: passed/, 'proxy_pass_header date'); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
116 like(http_get('/passdate/'), qr/Server: passed/, 'proxy_pass_header server'); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
117 unlike(http_get('/passdate/no/'), qr/Date/, 'proxy_pass_header no date'); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
118 unlike(http_get('/passdate/no/'), qr/Server/, 'proxy_pass_header no server'); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
119 |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 ############################################################################### |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 sub http_get_ims { |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
123 my ($url) = @_; |
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
124 return http(<<EOF); |
182
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 GET $url HTTP/1.0 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 Host: localhost |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 Connection: close |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 If-Modified-Since: blah |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 EOF |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 } |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
23f81eb0a817
Tests: proxy_set_header/fastcgi_param/scgi_param tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 ############################################################################### |
1762
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
134 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
135 sub http_daemon { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
136 my $server = IO::Socket::INET->new( |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
137 Proto => 'tcp', |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
138 LocalHost => '127.0.0.1', |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
139 LocalPort => port(8082), |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
140 Listen => 5, |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
141 Reuse => 1 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
142 ) |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
143 or die "Can't create listening socket: $!\n"; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
144 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
145 local $SIG{PIPE} = 'IGNORE'; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
146 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
147 while (my $client = $server->accept()) { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
148 $client->autoflush(1); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
149 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
150 my $headers = ''; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
151 my $uri = ''; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
152 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
153 while (<$client>) { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
154 $headers .= $_; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
155 last if (/^\x0d?\x0a?$/); |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
156 } |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
157 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
158 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
159 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
160 if ($uri =~ 'no') { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
161 print $client |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
162 'HTTP/1.0 200 OK' . CRLF . CRLF; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
163 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
164 } else { |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
165 print $client |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
166 'HTTP/1.0 200 OK' . CRLF . |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
167 'Date: passed' . CRLF . |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
168 'Server: passed' . CRLF . CRLF; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
169 } |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
170 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
171 close $client; |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
172 } |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
173 } |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
174 |
5ad8f0b5fa0f
Tests: tests for passing Date and Server headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1020
diff
changeset
|
175 ############################################################################### |