Headers are sometimes parsed as Bodies
dylanowen opened this issue · comments
Describe the bug
When parsing, headers are parsed as bodies if there is no newline at the end of the list of headers
To Reproduce
GET https://httpbin.org/anything
header: some-value
This file (make sure there is no newline after some-value
) will be parsed with the body header: some-value
instead of a header.
ex:
❯ dot-http test.http
GET https://httpbin.org/anything
HTTP/1.1 200 OK
date: Thu, 15 Oct 2020 22:38:11 GMT
content-type: application/json
content-length: 356
connection: keep-alive
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true
{
"args": {},
"data": "header: some-value",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Content-Length": "18",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-5f88cf53-311f5ef9437856d262e194b7"
},
"json": null,
"method": "GET",
"origin": "136.25.152.34",
"url": "https://httpbin.org/anything"
}
where I would have expected the result to be
❯ dot-http test.http
GET https://httpbin.org/anything
HTTP/1.1 200 OK
date: Thu, 15 Oct 2020 22:38:42 GMT
content-type: application/json
content-length: 338
connection: keep-alive
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Header": "some-value",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-5f88cf72-30ea80ac0c73b2840fcf5609"
},
"json": null,
"method": "GET",
"origin": "136.25.152.34",
"url": "https://httpbin.org/anything"
}
Please complete the following information:
- OS: Mac 10.15.7
- Version: https://github.com/bayne/dot-http/tree/5ca545bb444156046b6fe2409780ae2aff27ecb4/src
Additional context
It's almost like we need to change this line
dot-http/src/parser/parser.pest
Line 21 in 5ca545b
CRLF*
be CRLF+
but that causes it's own problems.