Mercurial > hg > nginx-tests
comparison not_modified_proxy.t @ 638:f758c780c508
Tests: If-Unmodified-Since for not modified filter with proxy.
This covers "header already sent" alerts seen for responses from cache.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 29 Jul 2015 13:55:27 +0300 |
parents | 2cd00179f4b2 |
children | 2d10f958741d |
comparison
equal
deleted
inserted
replaced
637:443848f28a73 | 638:f758c780c508 |
---|---|
24 ############################################################################### | 24 ############################################################################### |
25 | 25 |
26 select STDERR; $| = 1; | 26 select STDERR; $| = 1; |
27 select STDOUT; $| = 1; | 27 select STDOUT; $| = 1; |
28 | 28 |
29 my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(9) | 29 my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(12) |
30 ->write_file_expand('nginx.conf', <<'EOF'); | 30 ->write_file_expand('nginx.conf', <<'EOF')->todo_alerts(); |
31 | 31 |
32 %%TEST_GLOBALS%% | 32 %%TEST_GLOBALS%% |
33 | 33 |
34 daemon off; | 34 daemon off; |
35 | 35 |
40 %%TEST_GLOBALS_HTTP%% | 40 %%TEST_GLOBALS_HTTP%% |
41 | 41 |
42 proxy_cache_path %%TESTDIR%%/cache keys_zone=one:1m; | 42 proxy_cache_path %%TESTDIR%%/cache keys_zone=one:1m; |
43 | 43 |
44 proxy_set_header If-Modified-Since ""; | 44 proxy_set_header If-Modified-Since ""; |
45 proxy_set_header If-Unmodified-Since ""; | |
45 proxy_set_header If-None-Match ""; | 46 proxy_set_header If-None-Match ""; |
46 | 47 |
47 server { | 48 server { |
48 listen 127.0.0.1:8080; | 49 listen 127.0.0.1:8080; |
49 server_name localhost; | 50 server_name localhost; |
84 | 85 |
85 like(http_get_ims('/t', $lm), qr/ 304 /, 'if-modified-since'); | 86 like(http_get_ims('/t', $lm), qr/ 304 /, 'if-modified-since'); |
86 like(http_get_ims('/proxy/t', $lm), qr/ 200 /, 'ims proxy ignored'); | 87 like(http_get_ims('/proxy/t', $lm), qr/ 200 /, 'ims proxy ignored'); |
87 like(http_get_ims('/cache/t', $lm), qr/ 304 /, 'ims from cache'); | 88 like(http_get_ims('/cache/t', $lm), qr/ 304 /, 'ims from cache'); |
88 | 89 |
90 $t1 = 'Fri, 05 Jul 1985 14:30:52 GMT'; | |
91 | |
92 like(http_get_iums('/t', $t1), qr/ 412 /, 'if-unmodified-since'); | |
93 like(http_get_iums('/proxy/t', $t1), qr/ 200 /, 'iums proxy ignored'); | |
94 like(http_get_iums('/cache/t', $t1), qr/ 412 /, 'iums from cache'); | |
95 | |
89 like(http_get_inm('/t', $etag), qr/ 304 /, 'if-none-match'); | 96 like(http_get_inm('/t', $etag), qr/ 304 /, 'if-none-match'); |
90 like(http_get_inm('/proxy/t', $etag), qr/ 200 /, 'inm proxy ignored'); | 97 like(http_get_inm('/proxy/t', $etag), qr/ 200 /, 'inm proxy ignored'); |
91 like(http_get_inm('/cache/t', $etag), qr/ 304 /, 'inm from cache'); | 98 like(http_get_inm('/cache/t', $etag), qr/ 304 /, 'inm from cache'); |
92 | 99 |
93 # backend response with ETag only, no Last-Modified | 100 # backend response with ETag only, no Last-Modified |
109 If-Modified-Since: $ims | 116 If-Modified-Since: $ims |
110 | 117 |
111 EOF | 118 EOF |
112 } | 119 } |
113 | 120 |
121 sub http_get_iums { | |
122 my ($url, $ims) = @_; | |
123 return http(<<EOF); | |
124 GET $url HTTP/1.0 | |
125 Host: localhost | |
126 If-Unmodified-Since: $ims | |
127 | |
128 EOF | |
129 } | |
130 | |
114 sub http_get_inm { | 131 sub http_get_inm { |
115 my ($url, $inm) = @_; | 132 my ($url, $inm) = @_; |
116 return http(<<EOF); | 133 return http(<<EOF); |
117 GET $url HTTP/1.0 | 134 GET $url HTTP/1.0 |
118 Host: localhost | 135 Host: localhost |