annotate expect-100-continue.t @ 64:726c3c2a8b8c

Tests: don't set worker_connections explicitly.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 26 Jan 2009 17:02:57 +0300
parents 53eff3a83886
children 1c0ec30614c6
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28 master_process off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
29 daemon off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
30
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31 events {
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 http {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 access_log off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 root %%TESTDIR%%;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38 client_body_temp_path %%TESTDIR%%/client_body_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 proxy_temp_path %%TESTDIR%%/proxy_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42 server {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 listen 127.0.0.1:8080;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 server_name localhost;
63
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
45 location / {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
46 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
47 }
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
48 location /local {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
49 }
53
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 }
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53 EOF
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 $t->run();
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 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
60
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61 # 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
62 #
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 # - 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
64 # 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
65 # 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
66 # 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
67 # (or earlier) client.
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 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
70
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
71 ###############################################################################
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
72
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
73 sub http_100_request {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74 my ($url, $version) = @_;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75 my $r = http(<<EOF);
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 POST $url HTTP/$version
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77 Host: localhost
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78 Expect: 100-continue
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 Content-Length: 0
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 Connection: close
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 EOF
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 }
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85 ###############################################################################