Skip to content

Header names are not case-sensitive #51

Description

@marcj

https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive

Currently the code heavily relies on case-sensitive names.

Also Content-Type can contain a charset or additional information after ; character. Example: Content-Type: application/x-www-form-urlencoded; charset=utf-8 Such header break currently content parsing because of this.

We tried to fix it in PPM: https://github.com/php-pm/php-pm/blob/master/React/RequestParser.php#L18, but I believe we should fix it directly in reactphp/http.

Activity

  1. WyriHaximus commented on Mar 19, 2016

    @WyriHaximus
    Member

    Thanks for reporting and you're absolutely right, this has been on my mind for a while. I'm in favor of strtolower all the header names.

    @clue what is your take on this?

  2. WyriHaximus commented on Mar 19, 2016

    @WyriHaximus
    Member

    Or could go for a class that behaves as an array and makes them case-insensitive

  3. clue commented on Mar 20, 2016

    @clue
    Member

    but I believe we should fix it directly in reactphp/http

    Absolutely! 👍

    Afaict most occurrences will be replaced with PR #41 anyway, but we should definitely keep an eye on this.

    I'm in favor of strtolower all the header names.

    Yeah, this should do it for now (http://php.net/array_change_key_case).

    Eventually we will look into supporting PSR-7 (#28), by then we will also follow proper message semantics while preserving header case information.

    FWIW, RFC 2616 has been replaced with this:

    Each header field consists of a case-insensitive field name followed by […]
    http://tools.ietf.org/html/rfc7230#section-3.2

  4. pwhelan commented on Mar 22, 2016

    @pwhelan

    I actually went ahead and implemented a fix in PR #53 since I needed a fix for a work project. Hopefully #41 gets merged soon so I can drop my fix.

  5. andig commented on Oct 23, 2016

    @andig
    Contributor

    Will we ever see #41? It's a year in making now (sad).

  6. WyriHaximus commented on Oct 23, 2016

    @WyriHaximus
    Member

    @andig It's nearing completion see #41 (comment) see the issues mentioned in that comment. You're input on those is valued 👍

  7. self-assigned this
    on Feb 10, 2017
  8. added this to the v0.4.4 milestone on Feb 10, 2017
  9. clue commented on Feb 10, 2017

    @clue
    Member

    I'm currently looking into this and will file a PR for the upcoming v0.4.4 release. See #103 for the first step here.

  10. reopened this on Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions