Mercurial > hg > nginx-tests
comparison expect-100-continue.t @ 53:c8a816c678e1
Tests: add tests for Expect header handling.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 17 Dec 2008 17:55:46 +0300 |
parents | |
children | 2020bf9c75ce |
comparison
equal
deleted
inserted
replaced
52:405e8ca11c77 | 53:c8a816c678e1 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for Expect: 100-continue support. | |
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; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new()->plan(2); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 master_process off; | |
29 daemon off; | |
30 | |
31 events { | |
32 worker_connections 1024; | |
33 } | |
34 | |
35 http { | |
36 access_log off; | |
37 root %%TESTDIR%%; | |
38 | |
39 client_body_temp_path %%TESTDIR%%/client_body_temp; | |
40 fastcgi_temp_path %%TESTDIR%%/fastcgi_temp; | |
41 proxy_temp_path %%TESTDIR%%/proxy_temp; | |
42 | |
43 server { | |
44 listen 127.0.0.1:8080; | |
45 server_name localhost; | |
46 } | |
47 } | |
48 | |
49 EOF | |
50 | |
51 $t->run(); | |
52 | |
53 ############################################################################### | |
54 | |
55 like(http_100_request('/', '1.1'), qr/100/, 'expect 100 continue'); | |
56 | |
57 TODO: { | |
58 local $TODO = 'patch under review'; | |
59 | |
60 # From RFC 2616, 8.2.3 Use of the 100 (Continue) Status: | |
61 # | |
62 # - An origin server SHOULD NOT send a 100 (Continue) response if | |
63 # the request message does not include an Expect request-header | |
64 # field with the "100-continue" expectation, and MUST NOT send a | |
65 # 100 (Continue) response if such a request comes from an HTTP/1.0 | |
66 # (or earlier) client. | |
67 | |
68 unlike(http_100_request('/', '1.0'), qr/100/, 'no 100 continue via http 1.0'); | |
69 | |
70 } | |
71 | |
72 ############################################################################### | |
73 | |
74 sub http_100_request { | |
75 my ($url, $version) = @_; | |
76 my $r = http(<<EOF); | |
77 POST $url HTTP/$version | |
78 Host: localhost | |
79 Expect: 100-continue | |
80 Content-Length: 0 | |
81 Connection: close | |
82 | |
83 EOF | |
84 } | |
85 | |
86 ############################################################################### |