MCPcopy
hub / github.com/caddyserver/caddy / prepareTestRequest

Function prepareTestRequest

modules/caddyhttp/reverseproxy/retries_test.go:28–31  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
28func 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

Calls 1

PrepareRequestFunction · 0.92

Tested by

no test coverage detected