2012-05-11 12:57:38 +04:00
|
|
|
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
|
|
|
use lib 'lib';
|
2013-05-08 06:27:48 +04:00
|
|
|
use t::TestNginxLua;
|
2012-10-10 09:41:59 +04:00
|
|
|
use t::StapThread;
|
|
|
|
|
|
|
|
our $GCScript = $t::StapThread::GCScript;
|
|
|
|
our $StapScript = $t::StapThread::StapScript;
|
2012-05-11 12:57:38 +04:00
|
|
|
|
|
|
|
#worker_connections(1014);
|
|
|
|
#master_on();
|
|
|
|
#workers(2);
|
|
|
|
#log_level('warn');
|
|
|
|
|
|
|
|
repeat_each(2);
|
|
|
|
|
2013-06-19 06:09:14 +04:00
|
|
|
plan tests => repeat_each() * (blocks() * 3 + 2);
|
2012-05-11 12:57:38 +04:00
|
|
|
|
|
|
|
#no_diff();
|
|
|
|
#no_long_string();
|
|
|
|
run_tests();
|
|
|
|
|
|
|
|
__DATA__
|
|
|
|
|
2012-05-11 17:59:33 +04:00
|
|
|
=== TEST 1: If-Modified-Since true
|
2012-05-11 12:57:38 +04:00
|
|
|
--- config
|
|
|
|
location /lua {
|
|
|
|
content_by_lua '
|
|
|
|
ngx.header.last_modified = "Thu, 10 May 2012 07:50:59 GMT"
|
|
|
|
ngx.say("hello")
|
|
|
|
';
|
|
|
|
}
|
|
|
|
--- request
|
|
|
|
GET /lua
|
|
|
|
--- more_headers
|
|
|
|
If-Modified-Since: Thu, 10 May 2012 07:50:59 GMT
|
|
|
|
--- response_body
|
|
|
|
--- error_code: 304
|
|
|
|
--- no_error_log
|
|
|
|
[error]
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-11 17:59:33 +04:00
|
|
|
=== TEST 2: If-Modified-Since true
|
2012-05-11 12:57:38 +04:00
|
|
|
--- config
|
|
|
|
location /lua {
|
|
|
|
if_modified_since before;
|
|
|
|
content_by_lua '
|
|
|
|
ngx.header.last_modified = "Thu, 10 May 2012 07:50:48 GMT"
|
|
|
|
ngx.say("hello")
|
|
|
|
';
|
|
|
|
}
|
|
|
|
--- request
|
|
|
|
GET /lua
|
|
|
|
--- more_headers
|
|
|
|
If-Modified-Since: Thu, 10 May 2012 07:50:59 GMT
|
|
|
|
--- response_body
|
|
|
|
--- error_code: 304
|
|
|
|
--- no_error_log
|
|
|
|
[error]
|
|
|
|
|
2012-05-11 17:59:33 +04:00
|
|
|
|
|
|
|
|
|
|
|
=== TEST 3: If-Unmodified-Since false
|
|
|
|
--- config
|
|
|
|
location /lua {
|
|
|
|
#if_modified_since before;
|
|
|
|
content_by_lua '
|
|
|
|
ngx.header.last_modified = "Thu, 10 May 2012 07:50:48 GMT"
|
2013-06-19 06:09:14 +04:00
|
|
|
local ok, err = ngx.say("hello")
|
|
|
|
if not ok then
|
|
|
|
ngx.log(ngx.WARN, "say failed: ", err)
|
|
|
|
end
|
2012-05-11 17:59:33 +04:00
|
|
|
';
|
|
|
|
}
|
|
|
|
--- request
|
|
|
|
GET /lua
|
|
|
|
--- more_headers
|
|
|
|
If-Unmodified-Since: Thu, 10 May 2012 07:50:47 GMT
|
2012-10-10 09:41:59 +04:00
|
|
|
|
|
|
|
--- stap2 eval: $::StapScript
|
|
|
|
--- stap eval: $::GCScript
|
|
|
|
--- stap_out
|
2013-06-19 06:09:14 +04:00
|
|
|
terminate 1: ok
|
2012-10-10 09:41:59 +04:00
|
|
|
delete thread 1
|
|
|
|
|
2012-05-11 17:59:33 +04:00
|
|
|
--- response_body_like: 412 Precondition Failed
|
|
|
|
--- error_code: 412
|
|
|
|
--- error_log
|
2013-06-19 06:09:14 +04:00
|
|
|
say failed: nginx output filter error
|
|
|
|
--- no_error_log
|
|
|
|
[error]
|
2012-05-11 17:59:33 +04:00
|
|
|
|