comparison proxy_merge_headers.t @ 182:23f81eb0a817

Tests: proxy_set_header/fastcgi_param/scgi_param tests. These tests cover several problems, in particular ticket #45 (http://trac.nginx.org/nginx/ticket/45).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 08 Nov 2011 21:03:06 +0300
parents
children 101b092b67e2
comparison
equal deleted inserted replaced
181:e4024348b5ed 182:23f81eb0a817
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for proxy_set_header inheritance.
6
7 ###############################################################################
8
9 use warnings;
10 use strict;
11
12 use Test::More;
13
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
15
16 use lib 'lib';
17 use Test::Nginx;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(3)
25 ->write_file_expand('nginx.conf', <<'EOF');
26
27 %%TEST_GLOBALS%%
28
29 daemon off;
30
31 events {
32 }
33
34 http {
35 %%TEST_GLOBALS_HTTP%%
36
37 proxy_cache_path %%TESTDIR%%/cache levels=1:2
38 keys_zone=NAME:10m;
39
40 proxy_set_header X-Blah "blah";
41
42 server {
43 listen 127.0.0.1:8080;
44 server_name localhost;
45
46 proxy_cache NAME;
47
48 location / {
49 proxy_pass http://127.0.0.1:8081;
50 }
51
52 location /no/ {
53 proxy_pass http://127.0.0.1:8081;
54 proxy_cache off;
55 }
56
57 location /setbody/ {
58 proxy_pass http://127.0.0.1:8081;
59 proxy_set_body "body";
60 }
61 }
62
63 server {
64 listen 127.0.0.1:8081;
65 server_name localhost;
66
67 location / {
68 return 200 "ims=$http_if_modified_since;blah=$http_x_blah;";
69 }
70 }
71 }
72
73 EOF
74
75 $t->run();
76
77 ###############################################################################
78
79 like(http_get_ims('/'), qr/ims=;blah=blah;/,
80 'if-modified-since cleared with cache');
81
82 TODO: {
83 local $TODO = 'not yet';
84
85 like(http_get_ims('/no/'), qr/ims=blah;blah=blah;/,
86 'if-modified-since preserved without cache');
87
88 }
89
90 TODO: {
91 local $TODO = 'not yet';
92
93 like(http_get_ims('/setbody/'), qr/blah=blah;/,
94 'proxy_set_header inherited with proxy_set_body');
95
96 }
97
98 ###############################################################################
99
100 sub http_get_ims {
101 my ($url) = @_;
102 return http(<<EOF);
103 GET $url HTTP/1.0
104 Host: localhost
105 Connection: close
106 If-Modified-Since: blah
107
108 EOF
109 }
110
111 ###############################################################################