Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/webrick/httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def read_body(socket, block)
if @remaining_size > 0 && @socket.eof?
raise HTTPStatus::BadRequest, "invalid body size."
end
elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
elsif BODY_CONTAINABLE_METHODS.member?(@request_method) && [email protected]
raise HTTPStatus::LengthRequired
end
return @body
Expand Down
12 changes: 12 additions & 0 deletions test/webrick/test_httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@ def test_continue_not_sent
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_
Expand Down