Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UTF-8 in headers is not handled correctly #1061

@Avamander

Description

@Avamander

It seems like UTF-8 content in response headers causes an error due to the following code:

for header in response_headers:
    towrite.append(('%s: %s\r\n' % header).encode('latin-1'))

I can't find a spec saying that response header values have to be Latin-1, I'm not the only one for whom it does not seem to be specified. In the case of H2 the RFC says: "Just as in HTTP/1.x, header field names are strings of ASCII characters".

This leads me to believe that the values should not be forcefully encoded as Latin-1, valid UTF-8 should pass through unmodified. Alternatively, for ease-of-use, eventlet should %-encode any UTF-8 values instead of erroring out like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions