prepareTestRequest injects the context values that ServeHTTP and proxyLoopIteration require (caddy.ReplacerCtxKey, VarsCtxKey, etc.) using the same helper that the real HTTP server uses. A zero-value Server is passed so that caddyhttp.ServerCtxKey is set to a non-nil pointer; reverseProxy dereferen
(req *http.Request)
| 26 | // A zero-value Server is passed so that caddyhttp.ServerCtxKey is set to a |
| 27 | // non-nil pointer; reverseProxy dereferences it to check ShouldLogCredentials. |
| 28 | func prepareTestRequest(req *http.Request) *http.Request { |
| 29 | repl := caddy.NewReplacer() |
| 30 | return caddyhttp.PrepareRequest(req, repl, nil, &caddyhttp.Server{}) |
| 31 | } |
| 32 | |
| 33 | // closeOnCloseReader is an io.ReadCloser whose Close method actually makes |
| 34 | // subsequent reads fail, mimicking the behaviour of a real HTTP request body |
no test coverage detected