-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle exceptions? #5358
Comments
Looks like a dup of #3287
|
Hi @derlih , Best regards |
Hi @fpgamaster , |
Hi @derlih , Best regards |
Hi @fpgamaster , def handler(connection):
try:
server.handle_http(connection)
except aiohttp.BadHTTP:
pass # What should be here? |
Hi @derlih , Best regards |
I think as mentioned in the duplicate issue, we just want to send a 400 response (if/when possible), and probably log the error somewhere. |
Is there still no found way of handling this exception? Any HTTPS request on a public HTTP API exposes this error. |
Hello. However i would like an option to respond with something like Yes, in production web server/nginx would cut off a malformed request and it would not make it to aiohttp. |
@km445 this does not sound right. Per HTTP specs, an HTTP response is to be sent after receiving an HTTP request. So if the client is still in a state of sending the request over the wire, I would expect it to get confused if you send back something like this w/o first consuming the request. |
I'm going to close this one in favour of the duplicate issue (#3287). |
🐞 Describe the bug
The following exception happens when trying to connect to http server using https client:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
💡 To Reproduce
Start an http server and connect to it using any browser or client using https
💡 Expected behavior
A way to handle this exception. It cannot be handled using middlewares.
📋 Logs/tracebacks
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
The text was updated successfully, but these errors were encountered: