annotate expect-100-continue.t @ 63:53eff3a83886

Tests: fix expect-100-continue for 0.7.31. In nginx 0.7.31 processing of "Expect" header only happens while actually reading request body. Add proxy_pass as it always reads request body.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 26 Jan 2009 03:52:57 +0300
parents 2020bf9c75ce
children 726c3c2a8b8c
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 worker_connections 1024;
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 http {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 access_log off;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 root %%TESTDIR%%;
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 client_body_temp_path %%TESTDIR%%/client_body_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41 proxy_temp_path %%TESTDIR%%/proxy_temp;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 server {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 listen 127.0.0.1:8080;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45 server_name localhost;
63
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
46 location / {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
47 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
48 }
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
49 location /local {
53eff3a83886 Tests: fix expect-100-continue for 0.7.31.
Maxim Dounin <mdounin@mdounin.ru>
parents: 55
diff changeset
50 }
53
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 EOF
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 $t->run();
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 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
61
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 # 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
63 #
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 # - 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
65 # 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
66 # 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
67 # 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
68 # (or earlier) client.
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 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
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74 sub http_100_request {
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75 my ($url, $version) = @_;
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 my $r = http(<<EOF);
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77 POST $url HTTP/$version
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78 Host: localhost
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 Expect: 100-continue
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 Content-Length: 0
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81 Connection: close
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 EOF
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
c8a816c678e1 Tests: add tests for Expect header handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86 ###############################################################################