From a4fa58f9ab9883a03bf7ed95655501acfb2fa554 Mon Sep 17 00:00:00 2001 From: nahi Date: Fri, 10 Sep 2010 10:20:35 +0000 Subject: * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#continue): add method for generating HTTP/1.1 100 continue response if the client expects it, otherwise does nothing. Patch by Brian Candler. ref #855. * test/webrick/test_httprequest.rb: test added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/webrick/test_httprequest.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/webrick/test_httprequest.rb b/test/webrick/test_httprequest.rb index 4a1db38bca..7869c21795 100644 --- a/test/webrick/test_httprequest.rb +++ b/test/webrick/test_httprequest.rb @@ -305,6 +305,37 @@ class TestWEBrickHTTPRequest < Test::Unit::TestCase assert(req.ssl?) end + def test_continue_sent + msg = <<-_end_of_message_ + POST /path HTTP/1.1 + Expect: 100-continue + + _end_of_message_ + msg.gsub!(/^ {6}/, "") + req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP) + req.parse(StringIO.new(msg)) + assert req['expect'] + l = msg.size + req.continue + assert_not_equal l, msg.size + assert_match /HTTP\/1.1 100 continue\r\n\r\n\z/, msg + assert !req['expect'] + end + + def test_continue_not_sent + msg = <<-_end_of_message_ + POST /path HTTP/1.1 + + _end_of_message_ + msg.gsub!(/^ {6}/, "") + req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP) + req.parse(StringIO.new(msg)) + assert !req['expect'] + l = msg.size + req.continue + assert_equal l, msg.size + end + def test_bad_messages param = "foo=1;foo=2;foo=3;bar=x" msg = <<-_end_of_message_ -- cgit v1.2.3