annotate expect-100-continue.t @ 107:1c0ec30614c6

Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks. TEST_GLOBALS replaces previously used -g switch. This allows tests to be executed on 0.6.* branch. For compatibility with old tests -g switch will be used if TEST_GLOBALS wasn't expaneded in config. TEST_GLOBALS_HTTP replaces multiple variables (access_log, root, client_body_temp_path, proxy_temp_path, fastcgi_temp_path) previously specified directly in test configs. This change reduce duplication and allows tests to be used with nginx compiled without fastcgi and/or proxy modules (as proxy_temp_path and fastcgi_temp_path are added conditionally).
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 14 Oct 2009 02:23:52 +0400
parents 726c3c2a8b8c
children 8ac1faaddd2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 # (C) Maxim Dounin
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 # Tests for Expect: 100-continue support.
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7 ###############################################################################
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 use warnings;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10 use strict;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 use Test::More;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 use lib 'lib';
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use Test::Nginx;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 ###############################################################################
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 select STDERR; $| = 1;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 select STDOUT; $| = 1;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 my $t = Test::Nginx->new()->plan(2);
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 $t->write_file_expand('nginx.conf', <<'EOF');
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
28 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
29
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
30 master_process off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31 daemon off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33 events {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 64
diff changeset
37 %%TEST_GLOBALS_HTTP%%
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 server {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 listen 127.0.0.1:8080;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41 server_name localhost;
63
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
42 location / {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
43 proxy_pass http://localhost:8080/local;
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
44 }
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
45 location /local {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
46 }
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48 }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 EOF
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 $t->run();
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 ###############################################################################
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56 like(http_100_request('/', '1.1'), qr/100/, 'expect 100 continue');
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 # From RFC 2616, 8.2.3 Use of the 100 (Continue) Status:
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 #
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 # - An origin server SHOULD NOT send a 100 (Continue) response if
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61 # the request message does not include an Expect request-header
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 # field with the "100-continue" expectation, and MUST NOT send a
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 # 100 (Continue) response if such a request comes from an HTTP/1.0
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 # (or earlier) client.
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66 unlike(http_100_request('/', '1.0'), qr/100/, 'no 100 continue via http 1.0');
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
68 ###############################################################################
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
69
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
70 sub http_100_request {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
71 my ($url, $version) = @_;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
72 my $r = http(<<EOF);
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
73 POST $url HTTP/$version
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74 Host: localhost
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75 Expect: 100-continue
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 Content-Length: 0
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77 Connection: close
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 EOF
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82 ###############################################################################