Skip to content
Open
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
4 changes: 4 additions & 0 deletions lib/async/http/protocol/http1/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def next_request
end

return request
rescue ::Protocol::HTTP1::LineLengthError
# We don't know whether the request line or a header line was too long, so we respond with the more common case (URI Too Long):
fail_request(414)
raise
rescue ::Protocol::HTTP1::BadRequest
fail_request(400)
# Conceivably we could retry here, but we don't really know how bad the error is, so it's better to just fail:
Expand Down
17 changes: 17 additions & 0 deletions test/async/http/protocol/http11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ def around

expect(response.status).to be == 400
end

with "maximum line length" do
let(:maximum_line_length) {1024}
let(:protocol) {subject.new(maximum_line_length: maximum_line_length)}

it "should fail with 414 when the request line is too long" do
response = client.get("/?q=#{"a" * maximum_line_length}")

expect(response.status).to be == 414
end

it "should fail with 414 when a header line is too long" do
response = client.get("/", {"x-padding" => "a" * maximum_line_length})

expect(response.status).to be == 414
end
end
end

with "head request" do
Expand Down
Loading