Skip to content

FastCGI parameters are encoded using ASCII instead of UTF-8 #4

@che2116

Description

@che2116

Hi,
Thanks for the library — it's very useful!

I encountered an issue related to parameter encoding. When sending FastCGI requests, the library encodes parameters using ASCII:

File: FastCGIClient.py, function: __encodeNameValueParams, code line: 169

        return record + bytearray(str(name).encode('ascii')) + bytearray(str(value).encode('ascii'))

This causes a problem when parameters contain non-ASCII characters (e.g., in SCRIPT_FILENAME, QUERY_STRING, or custom headers), resulting in a UnicodeEncodeError.

According to the FastCGI specification and common usage (e.g., PHP-FPM, Nginx), UTF-8 should be used for encoding strings in most environments.

Suggested fix:

Update the encoding line to:

        return record + bytearray(str(name).encode('utf-8')) + bytearray(str(value).encode('utf-8'))

Let me know if you’d like a pull request — I’d be happy to help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions