Mercurial > hg > nginx-tests
comparison not-modified.t @ 111:02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 15 Oct 2009 16:08:16 +0400 |
parents | |
children | 4edfc490b6e5 |
comparison
equal
deleted
inserted
replaced
110:51f3c88b2930 | 111:02838a17ba9a |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for not modified filter module. | |
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()->plan(4) | |
25 ->write_file_expand('nginx.conf', <<'EOF'); | |
26 | |
27 %%TEST_GLOBALS%% | |
28 | |
29 master_process off; | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 server { | |
39 listen 127.0.0.1:8080; | |
40 server_name localhost; | |
41 | |
42 location / { | |
43 if_modified_since before; | |
44 } | |
45 } | |
46 } | |
47 | |
48 EOF | |
49 | |
50 $t->write_file('t', ''); | |
51 | |
52 $t->run(); | |
53 | |
54 ############################################################################### | |
55 | |
56 like(http_get_ims('/t', 'Wed, 08 Jul 2037 22:53:52 GMT'), qr/304/, | |
57 '0x7F000000'); | |
58 | |
59 TODO: { | |
60 local $TODO = 'not yet'; | |
61 | |
62 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:07 GMT'), qr/304/, | |
63 '0x7FFFFFFF'); | |
64 | |
65 } | |
66 | |
67 SKIP: { | |
68 skip "only for 32-bit time_t", 2 if (gmtime(0xFFFFFFFF))[5] == 206; | |
69 | |
70 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:08 GMT'), qr/200/, | |
71 '0x7FFFFFFF + 1'); | |
72 like(http_get_ims('/t', 'Fri, 25 Feb 2174 09:42:23 GMT'), qr/200/, | |
73 '0x17FFFFFFF'); | |
74 } | |
75 | |
76 ############################################################################### | |
77 | |
78 sub http_get_ims { | |
79 my ($url, $ims) = @_; | |
80 return http(<<EOF); | |
81 GET $url HTTP/1.0 | |
82 Host: localhost | |
83 If-Modified-Since: $ims | |
84 | |
85 EOF | |
86 } | |
87 | |
88 ############################################################################### |