You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes: #69
Replace makeRequestForValidation (which used r.Clone()) with
withPrefixStripped, which temporarily modifies the request's path
fields in place and restores them after validation.
r.Clone() shallow-copies the Body, so when validation consumed the
body on the clone, the original request passed to the handler had an
empty body, causing 'EOF' errors on decode.
The new approach mutates the path fields for the duration of route
finding and validation, then restores them before the handler or error
handler sees the request. No clone, no body sharing, no buffering of
potentially large request bodies.
The r.Clone() was only done as a way to back up the request URI to
send the prefix-stripped request into validation.
Fixes#69
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
// Note that this is an inline-and-modified version of `validateRequest`, with a simplified control flow and providing full access to the `error` for the `ErrorHandlerWithOpts` function.
212
225
funcperformRequestValidationForErrorHandlerWithOpts(next http.Handler, w http.ResponseWriter, r*http.Request, router routers.Router, options*Options) {
213
-
// Build a (possibly prefix-stripped) request for validation, but keep
214
-
// the original so the downstream handler sees the un-modified path.
0 commit comments