Skip to content

Set RAW_URI in the WSGI environ - #928

Open
blarghmatey wants to merge 1 commit into
emmett-framework:masterfrom
blarghmatey:wsgi-raw-uri
Open

blarghmatey wants to merge 1 commit into
emmett-framework:masterfrom
blarghmatey:wsgi-raw-uri

Conversation

@blarghmatey

Copy link
Copy Markdown

Close #927

Adds RAW_URI to the WSGI environ: the request's path and query as sent, still percent-encoded, decoded as latin-1 the same way QUERY_STRING already is. I used the gunicorn key rather than REQUEST_URI because opentelemetry-instrumentation-wsgi checks RAW_URI first.

One difference from gunicorn: gunicorn puts the whole request-line target in RAW_URI, so an absolute-form GET http://host/path or a #fragment comes through verbatim. Here it's path_and_query(), so those give /path. For the middleware that reads it, that's the part they want.

test_raw_uri covers a percent-encoded non-ASCII path with an encoded %2F: PATH_INFO is decoded, RAW_URI keeps the escapes. It fails without the change in callbacks.rs.

🤖 Generated with Claude Code

https://claude.ai/code/session_017Uj5u2SZz2LzrTff5TaM6y

PATH_INFO is percent-decoded, so the request target as sent was not
available anywhere in the environ. gunicorn exposes it as RAW_URI, and
opentelemetry-instrumentation-wsgi reads it before falling back to
wsgiref.util.request_uri(), which raises on Django apps once a path holds
a codepoint above U+00FF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Uj5u2SZz2LzrTff5TaM6y

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.

WSGI: expose the original request target as RAW_URI / REQUEST_URI

1 participant