Customize max_line_size and max_field_size in HttpParser?
- Vorherrschende Sprache
- Python
- Sterne
- 16.5k
- Forks
- 2.4k
- Ø Merge
- 17 Std. 22 Min.
- Gemergte PRs (30 T.)
- 212
Beschreibung
We're using `aiohttp` 2.x with Python 3.5.2 and trying to upgrade to the latest aiohttp 3.2.0 with Python 3.6.5.
We're getting errors such as these:
```
[2018-05-10 08:31:55 +0000] [12471] [ERROR] Error handling request
Traceback (most recent call last):
File "/project/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 235, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 297, in aiohttp._http_parser.HttpParser.feed_data
File "aiohttp/_http_parser.pyx", line 425, in aiohttp._http_parser.cb_on_header_value
aiohttp.http_exceptions.LineTooLong: 400, message='Got more than 8190 bytes (9383) when reading Header value is too long.'
```
This was happening in aiohttp 2.x as well, because I believe the standard specifies that length as the maximum, however the real world doesn't always agree with standards 😒
To fix this, with aiohttp 2.x we were monkey-patching [HttpParser](https://github.com/aio-libs/aiohttp/blob/3.2/aiohttp/_http_parser.pyx#L425) in order to override `max_line_size` and `max_field_size`. Here's the horrible things we've been doing: [gist](https://gist.github.com/alexandru/f68bc29aac2e4961f7720ecfba63afd3) — this file being imported in our `gunicorn_worker.py`.
Now that we've upgraded to 3.x, this monkey patching no longer works. Don't know why.
Any way to customize `max_line_size` and `max_field_size`?
Possibly without monkey patching, but not necessarily, atm I just want the thing to work?
Environment:
- Python 3.6.5
- aiohttp 3.2.0
- Gunicorn 19.8.1 (via `aiohttp.worker.GunicornWebWorker`)
See the full [requirements.txt](https://gist.github.com/alexandru/fa54cde5088be9fb6acb56808efb01f9) if interested.
Cheers,
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.