comparison http_expect_100_continue.t @ 148:b714d6df958c

Tests: rename some tests for better sorting. Use underscore instead of dash. Addtionally, rename some tests to better match "module" + "details" scheme used: use "http_" prefix for http core module tests, use "mail_" prefix for mail module tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 04 Mar 2011 16:07:15 +0300
parents expect-100-continue.t@8ac1faaddd2c
children c0ae29632905
comparison
equal deleted inserted replaced
147:fd865ada95c8 148:b714d6df958c
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()->has(qw/http proxy/)->plan(2);
25
26 $t->write_file_expand('nginx.conf', <<'EOF');
27
28 %%TEST_GLOBALS%%
29
30 master_process off;
31 daemon off;
32
33 events {
34 }
35
36 http {
37 %%TEST_GLOBALS_HTTP%%
38
39 server {
40 listen 127.0.0.1:8080;
41 server_name localhost;
42 location / {
43 proxy_pass http://localhost:8080/local;
44 }
45 location /local {
46 }
47 }
48 }
49
50 EOF
51
52 $t->run();
53
54 ###############################################################################
55
56 like(http_100_request('/', '1.1'), qr/100/, 'expect 100 continue');
57
58 # From RFC 2616, 8.2.3 Use of the 100 (Continue) Status:
59 #
60 # - An origin server SHOULD NOT send a 100 (Continue) response if
61 # the request message does not include an Expect request-header
62 # field with the "100-continue" expectation, and MUST NOT send a
63 # 100 (Continue) response if such a request comes from an HTTP/1.0
64 # (or earlier) client.
65
66 unlike(http_100_request('/', '1.0'), qr/100/, 'no 100 continue via http 1.0');
67
68 ###############################################################################
69
70 sub http_100_request {
71 my ($url, $version) = @_;
72 my $r = http(<<EOF);
73 POST $url HTTP/$version
74 Host: localhost
75 Expect: 100-continue
76 Content-Length: 0
77 Connection: close
78
79 EOF
80 }
81
82 ###############################################################################