Skip to content

Header parsing RFC compliance #302

@kelunik

Description

@kelunik

This library isn't compliant to the HTTP/1.1 RFC currently regarding header parsing. I wanted to open an issue for https://github.com/ringcentral/psr7, but issues are not available there.

There's no whitespace allowed before the colon (:) that separates field name and field value as defined in https://tools.ietf.org/html/rfc7230#section-3.2. This is further elaborated in https://tools.ietf.org/html/rfc7230#section-3.2.4.

I noticed this while I had a look at the regex we use in Aerys. That regex is also wrong, because it allows duplicate and optional \r and doesn't trim trailing whitespace correctly. Further post-processing isn't done, so trailing whitespace is included in the header value. We probably keep ignoring a missing \r, but will fix the latter issue in our code. I therefore built an optimized regex that you might want to use. If you use that regex, you must add a check that the number of lines is equal to the number of matches of preg_match_all().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions