Mercurial > hg > nginx-tests
annotate not-modified.t @ 118:4bf7a819358c
Tests: add some embedded perl tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 22 Dec 2009 01:59:01 +0300 |
parents | 4edfc490b6e5 |
children | 8ac1faaddd2c |
rev | line source |
---|---|
111
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for not modified filter module. |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 my $t = Test::Nginx->new()->plan(4) |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 master_process off; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 daemon off; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 events { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 http { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 server { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 listen 127.0.0.1:8080; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server_name localhost; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 location / { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 if_modified_since before; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 EOF |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 $t->write_file('t', ''); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 $t->run(); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 ############################################################################### |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 like(http_get_ims('/t', 'Wed, 08 Jul 2037 22:53:52 GMT'), qr/304/, |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 '0x7F000000'); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:07 GMT'), qr/304/, |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 '0x7FFFFFFF'); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 SKIP: { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 skip "only for 32-bit time_t", 2 if (gmtime(0xFFFFFFFF))[5] == 206; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:08 GMT'), qr/200/, |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 '0x7FFFFFFF + 1'); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 like(http_get_ims('/t', 'Fri, 25 Feb 2174 09:42:23 GMT'), qr/200/, |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 '0x17FFFFFFF'); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 ############################################################################### |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 sub http_get_ims { |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 my ($url, $ims) = @_; |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 return http(<<EOF); |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 GET $url HTTP/1.0 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 Host: localhost |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 If-Modified-Since: $ims |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 EOF |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 } |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
02838a17ba9a
Tests: add not modified filter (parse time, actually) tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 ############################################################################### |