summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-07-15 08:38:44 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-24 21:34:07 +0900
commited12019ce6abe87aac87ec77ac081d37b25180a2 (patch)
treeec2dd9fedab4f951fcf3483760adac5fd92ef5a2 /test
parent0fe6461148af5f27c2a89a6bb25b6709b9eaca49 (diff)
[ruby/webrick] Allow empty POST and PUT requests without content length
RFC 7230 section 3.3.3 allows for this. Fixes #30 https://github.com/ruby/webrick/commit/069e9b1908
Diffstat (limited to 'test')
-rw-r--r--test/webrick/test_httprequest.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/webrick/test_httprequest.rb b/test/webrick/test_httprequest.rb
index a594f14f72..759ccbdada 100644
--- a/test/webrick/test_httprequest.rb
+++ b/test/webrick/test_httprequest.rb
@@ -425,6 +425,18 @@ GET /
assert_equal l, msg.size
end
+ def test_empty_post
+ msg = <<-_end_of_message_
+ POST /path?foo=x;foo=y;foo=z;bar=1 HTTP/1.1
+ Host: test.ruby-lang.org:8080
+ Content-Type: application/x-www-form-urlencoded
+
+ _end_of_message_
+ req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
+ req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
+ req.body
+ end
+
def test_bad_messages
param = "foo=1;foo=2;foo=3;bar=x"
msg = <<-_end_of_message_