mirage / ocaml-cohttp

An OCaml library for HTTP clients and servers using Lwt or Async
Other
696 stars 172 forks source link

`header_io.ml`''s `parse` doesn't support multi-line "folded" headers #1033

Open askvortsov1 opened 1 month ago

askvortsov1 commented 1 month ago

The HTTP 1.1 spec allows for header values to be split across several lines:

HTTP/1.1 header field values can be folded onto multiple lines if the continuation line begins with a space or horizontal tab. All linear white space, including folding, has the same semantics as SP. A recipient MAY replace any linear white space with a single SP before interpreting the field value or forwarding the message downstream.

For example:

Header: value1, value2

should be parsed equivalently to:

Header: value1,
        value2

This has since been deprecated except for use within the message/http media type, but this occasionally pops up in the wild, and other HTTP header parsers support it according to this StackOverflow answer.

dinosaure commented 1 month ago

Note that unstrctrd was made for this specific purpose which concerns emails too.