Skip to content

fix(middleware): skip CleanPath for HTTP CONNECT requests#1092

Open
lihan3238 wants to merge 1 commit into
go-chi:masterfrom
lihan3238:fix-807
Open

fix(middleware): skip CleanPath for HTTP CONNECT requests#1092
lihan3238 wants to merge 1 commit into
go-chi:masterfrom
lihan3238:fix-807

Conversation

@lihan3238

Copy link
Copy Markdown

Closes #807

Summary

CleanPath middleware calls path.Clean() on the request path, but HTTP CONNECT requests use authority-form targets (host:port), not path-form URIs. path.Clean() corrupts these targets (e.g., example.com:8080example.com:8080 with altered RoutePath), causing route mismatches and 404 responses.

Fix

Skip CleanPath logic entirely for CONNECT method, passing the request through unchanged. This preserves the authority-form target per RFC 9110 Section 9.3.4.

Test Plan

HTTP CONNECT requests use authority-form targets (host:port), not
path-form. path.Clean() corrupts these targets, causing RoutePath
mismatches and 404 responses.

Skip the clean path logic for CONNECT method to preserve the
authority-form target.

Closes go-chi#807
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.

CleanPath middleware does not work correctly with http CONNECT requests

1 participant