Skip to content

Use latin-1 for WSGI environ path and headers - #1321

Open
patrick-immometrica wants to merge 2 commits into
pydantic:mainfrom
patrick-immometrica:wsgi-latin1
Open

patrick-immometrica wants to merge 2 commits into
pydantic:mainfrom
patrick-immometrica:wsgi-latin1

Conversation

@patrick-immometrica

@patrick-immometrica patrick-immometrica commented Nov 8, 2026 •

Copy link
Copy Markdown

Summary

PEP 3333 wants environ strings to hold the raw bytes decoded as latin-1. WSGITransport passed the decoded unicode path as PATH_INFO, and used ascii for header values. With a Flask/werkzeug app:

  • GET /caf%C3%A9 -> the app sees /caf�
  • GET /euro/%E2%82%AC -> UnicodeEncodeError inside werkzeug
  • a non-ASCII request or response header value -> UnicodeDecodeError / UnicodeEncodeError

PATH_INFO is now built from the raw path bytes (unquote_to_bytes on raw_path) and decoded as latin-1, and header values use latin-1 both ways. encode/httpx#1391 fixed the unquoting for this, but not the encoding, so the example in encode/httpx#1365 still failed.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/httpx2/httpx2/_transports/wsgi.py Resolved
@codspeed

codspeed Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing patrick-immometrica:wsgi-latin1 (d3744ef) with main (f4f65c1)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant