comparison not_modified_finalize.t @ 1096:2978c5212045

Tests: filter finalization in not modified filter.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 13 Dec 2016 20:08:03 +0300
parents
children fc3722dd8862
comparison
equal deleted inserted replaced
1095:b16d30a52753 1096:2978c5212045
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for not modified filter and filter finalization.
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 qw/ :DEFAULT :gzip /;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(1)
25 ->write_file_expand('nginx.conf', <<'EOF');
26
27 %%TEST_GLOBALS%%
28
29 daemon off;
30
31 events {
32 }
33
34 http {
35 %%TEST_GLOBALS_HTTP%%
36
37 proxy_cache_path %%TESTDIR%%/cache keys_zone=cache:1m;
38
39 server {
40 listen 127.0.0.1:8080;
41 server_name localhost;
42
43 error_page 412 /error412.html;
44
45 location / {
46 proxy_pass http://127.0.0.1:8081;
47 proxy_cache cache;
48 proxy_cache_lock on;
49 }
50
51 location /error412 {
52 }
53 }
54
55 server {
56 listen 127.0.0.1:8081;
57 server_name localhost;
58 }
59 }
60
61 EOF
62
63 $t->write_file('t.html', 'test file');
64 $t->write_file('error412.html', 'error412');
65
66 $t->run();
67
68 ###############################################################################
69
70 # we trigger filter finalization in not modified filter by using
71 # the If-Unmodified-Since/If-Match header;
72 # with cache enabled and updating bit set, this currently results in
73 # "stalled cache updating" alerts
74
75 like(http_match_get('/t.html'), qr//, 'request 412');
76
77 $t->todo_alerts();
78
79 ###############################################################################
80
81 sub http_match_get {
82 my ($url, %extra) = @_;
83 return http(<<EOF, %extra);
84 GET $url HTTP/1.0
85 Host: localhost
86 If-Match: tt
87
88 EOF
89 }
90
91 ###############################################################################