File: 072-conditional-get.t

package info (click to toggle)
nginx 1.18.0-6.1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,344 kB
  • sloc: ansic: 250,653; perl: 7,548; sh: 1,408; ruby: 879; python: 358; makefile: 338; awk: 36; cpp: 18
file content (90 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# vim:set ft= ts=4 sw=4 et fdm=marker:
use Test::Nginx::Socket::Lua;
use t::StapThread;

our $GCScript = $t::StapThread::GCScript;
our $StapScript = $t::StapThread::StapScript;

#worker_connections(1014);
#master_on();
#workers(2);
#log_level('warn');

repeat_each(2);

plan tests => repeat_each() * (blocks() * 3 + 2);

#no_diff();
#no_long_string();
run_tests();

__DATA__

=== TEST 1: If-Modified-Since true
--- 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]



=== TEST 2: If-Modified-Since true
--- 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]



=== 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"
            local ok, err = ngx.say("hello")
            if not ok then
                ngx.log(ngx.WARN, "say failed: ", err)
            end
        ';
    }
--- request
GET /lua
--- more_headers
If-Unmodified-Since: Thu, 10 May 2012 07:50:47 GMT

--- stap2 eval: $::StapScript
--- stap eval: $::GCScript
--- stap_out
terminate 1: ok
delete thread 1

--- response_body_like: 412 Precondition Failed
--- error_code: 412
--- error_log
say failed: nginx output filter error
--- no_error_log
[error]