# HG changeset patch # User Maxim Dounin # Date 1229525746 -10800 # Node ID c8a816c678e1aa8a8225ac1b54431e3f08b13dce # Parent 405e8ca11c77af8b3c7e125e2612e5f138888c48 Tests: add tests for Expect header handling. diff --git a/expect-100-continue.t b/expect-100-continue.t new file mode 100644 --- /dev/null +++ b/expect-100-continue.t @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +# (C) Maxim Dounin + +# Tests for Expect: 100-continue support. + +############################################################################### + +use warnings; +use strict; + +use Test::More; + +BEGIN { use FindBin; chdir($FindBin::Bin); } + +use lib 'lib'; +use Test::Nginx; + +############################################################################### + +select STDERR; $| = 1; +select STDOUT; $| = 1; + +my $t = Test::Nginx->new()->plan(2); + +$t->write_file_expand('nginx.conf', <<'EOF'); + +master_process off; +daemon off; + +events { + worker_connections 1024; +} + +http { + access_log off; + root %%TESTDIR%%; + + client_body_temp_path %%TESTDIR%%/client_body_temp; + fastcgi_temp_path %%TESTDIR%%/fastcgi_temp; + proxy_temp_path %%TESTDIR%%/proxy_temp; + + server { + listen 127.0.0.1:8080; + server_name localhost; + } +} + +EOF + +$t->run(); + +############################################################################### + +like(http_100_request('/', '1.1'), qr/100/, 'expect 100 continue'); + +TODO: { +local $TODO = 'patch under review'; + +# From RFC 2616, 8.2.3 Use of the 100 (Continue) Status: +# +# - An origin server SHOULD NOT send a 100 (Continue) response if +# the request message does not include an Expect request-header +# field with the "100-continue" expectation, and MUST NOT send a +# 100 (Continue) response if such a request comes from an HTTP/1.0 +# (or earlier) client. + +unlike(http_100_request('/', '1.0'), qr/100/, 'no 100 continue via http 1.0'); + +} + +############################################################################### + +sub http_100_request { + my ($url, $version) = @_; + my $r = http(<