Repository navigation
fix(httpv1): accept HTTP/1 messages with no header fields (#1041) - #1049
Conversation
2ea2efd to
0ab5320
Compare
|
Cross-review verdict on
Not Nits: Follow-up filed as #1050: |
RFC 9112 allows zero field lines, but `_read_http_header` unpacked the header's CRLF split two ways and refused a header that was only the start line, so `GET / HTTP/1.0\r\n\r\n` raised `ProtocolError` and `HTTPv1(method='GET', uri='/', http_version='1.1')` could not read back the bytes its own `make` built. `_test_start_line` mirrored the check, so the dispatcher answered `unknown HTTP version` for the same bytes. A CRLF-less header is now a start line with zero fields in both. That check was also what refused the HTTP/2 connection preface, whose header is exactly `PRI * HTTP/2.0`; both now refuse it by name (`_HTTP2_PREFACE_HEADER`), to the same `HTTP: invalid format`.
0ab5320 to
82ec132
Compare
|
Cross-review verdict on The diff over |
make pylint,make mypy,make isort)make testpasses, and a test case covers the changedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visibleWhat is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
Closes #1041.
_read_http_headerrefused a header with no CRLF, i.e. every message with zero field lines;_test_start_linemirrored it, so the dispatcher saidunknown HTTP versiontoo. Both now read it as a start line with zero fields.That check was also what kept the HTTP/2 preface (header
PRI * HTTP/2.0) out of HTTP/1. It is now refused by name (_HTTP2_PREFACE_HEADER, derived fromhttp._HTTP2_PREFACE), sameHTTP: invalid format; a regression test pins it in the parser, predicate and dispatcher.New tests: headerless request, headerless response with body,
make→readround trip, preface guard. The first three fail onmain. Two existing tests that asserted the oldProtocolErroras proof of delegation now assert the built bytes. Changelog pin 162 → 163.