Skip to content

Commit 0e9e0b5

Browse files
committed
added more tests for conditional GETs and 304 responses.
1 parent 54cd2fc commit 0e9e0b5

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

t/etag.t

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Test::Nginx::Socket;
55

66
#repeat_each(2);
77

8-
plan tests => repeat_each() * (5 * blocks() + 5);
8+
plan tests => repeat_each() * (5 * blocks() + 4);
99

1010
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1111

@@ -108,3 +108,80 @@ Last-Modified: Sat, 01 Mar 2014 01:02:38 GMT
108108
--- response_body:
109109
--- error_code: 304
110110
111+
112+
113+
=== TEST 4: flush all (not using ngx_srcache)
114+
--- config
115+
location /flush {
116+
set $memc_cmd 'flush_all';
117+
memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
118+
add_header X-Fetch-Status $srcache_fetch_status;
119+
add_header X-Store-Status $srcache_store_status;
120+
}
121+
--- response_headers
122+
Content-Type: text/plain
123+
Content-Length: 4
124+
X-Fetch-Status: BYPASS
125+
X-Store-Status: BYPASS
126+
127+
--- request
128+
GET /flush
129+
--- response_body eval: "OK\r\n"
130+
131+
132+
133+
=== TEST 5: basic fetch (cache miss, 304)
134+
--- config
135+
location /foo {
136+
default_type text/css;
137+
srcache_fetch GET /memc $uri;
138+
srcache_store PUT /memc $uri;
139+
140+
content_by_lua '
141+
ngx.header["ETag"] = [["abcd1234"]]
142+
ngx.header["Last-Modified"] = "Sat, 01 Mar 2014 01:02:38 GMT"
143+
ngx.say("hello")
144+
';
145+
#echo hello;
146+
add_header X-Fetch-Status $srcache_fetch_status;
147+
add_header X-Store-Status $srcache_store_status;
148+
}
149+
150+
location /memc {
151+
internal;
152+
153+
set $memc_key $query_string;
154+
set $memc_exptime 300;
155+
memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
156+
}
157+
--- request
158+
GET /foo
159+
--- more_headers
160+
If-None-Match: "abcd1234"
161+
--- response_headers
162+
Content-Length:
163+
X-Fetch-Status: MISS
164+
X-Store-Status: BYPASS
165+
Last-Modified: Sat, 01 Mar 2014 01:02:38 GMT
166+
--- response_body:
167+
--- error_code: 304
168+
--- wait: 0.1
169+
--- error_log
170+
--- log_level: debug
171+
172+
173+
174+
=== TEST 6: basic fetch (cache hit)
175+
--- config
176+
location /memc {
177+
#internal;
178+
179+
set $memc_key $query_string;
180+
set $memc_exptime 300;
181+
memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
182+
}
183+
--- request
184+
GET /memc?/foo
185+
--- response_body_like: 404 Not Found
186+
--- error_code: 404
187+

0 commit comments

Comments
 (0)