Skip to content

Commit 5e9a17c

Browse files
committed
Ignore bad requests.
1 parent 773b8d7 commit 5e9a17c

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

async-http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
3030
spec.add_dependency "io-stream", "~> 0.6"
3131
spec.add_dependency "metrics", "~> 0.12"
3232
spec.add_dependency "protocol-http", "~> 0.58"
33-
spec.add_dependency "protocol-http1", "~> 0.36"
33+
spec.add_dependency "protocol-http1", "~> 0.37"
3434
spec.add_dependency "protocol-http2", "~> 0.22"
3535
spec.add_dependency "protocol-url", "~> 0.2"
3636
spec.add_dependency "traces", "~> 0.10"

lib/async/http/protocol/http1/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def next_request
5353
end
5454

5555
return request
56-
rescue ::Protocol::HTTP1::BadRequest
56+
rescue ::Protocol::HTTP::BadRequest
5757
fail_request(400)
5858
# Conceivably we could retry here, but we don't really know how bad the error is, so it's better to just fail:
5959
raise

lib/async/http/server.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def accept(peer, address, task: Task.current)
5656
# If this returns nil, we assume that the connection has been hijacked.
5757
self.call(request)
5858
end
59+
rescue Protocol::HTTP::BadRequest
60+
# Ignore bad requests, just close the connection.
5961
ensure
6062
connection&.close
6163
end

releases.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Unreleased
44

55
- Fix `defer_stop` usage in `HTTP1::Server`, improving server graceful shutdown behavior.
6+
- Use more generic `Protocol::HTTP::BadRequest` exception in `HTTP1::Server` to handle bad requests, improving handling of more generic bad request errors.
7+
- Ignore `Protocol::HTTP::BadRequest` exceptions for the purpose of logging, to reduce noise from "expected" bad requests.
68

79
## v0.94.0
810

0 commit comments

Comments
 (0)