MCPcopy Create free account
hub / github.com/google/pprof / redirectWithQuery

Function redirectWithQuery

internal/driver/webui.go:223–229  ·  view source on GitHub ↗

redirectWithQuery responds with a given redirect code, preserving query parameters in the redirect URL. It does not convert relative paths to absolute paths like http.Redirect does, so that HTTPServerArgs.Handlers can generate relative redirects that work with the external prefixing.

(path string, code int)

Source from the content-addressed store, hash-verified

221// absolute paths like http.Redirect does, so that HTTPServerArgs.Handlers can
222// generate relative redirects that work with the external prefixing.
223func redirectWithQuery(path string, code int) http.HandlerFunc {
224 return func(w http.ResponseWriter, r *http.Request) {
225 pathWithQuery := &gourl.URL{Path: path, RawQuery: r.URL.RawQuery}
226 w.Header().Set("Location", pathWithQuery.String())
227 w.WriteHeader(code)
228 }
229}
230
231func isLocalhost(host string) bool {
232 return slices.Contains([]string{"localhost", "127.0.0.1", "[::1]", "::1"}, host)

Callers 2

serveWebInterfaceFunction · 0.85
defaultWebServerFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…