MCPcopy
hub / github.com/grafana/dskit / dumpRequestHeaders

Function dumpRequestHeaders

middleware/logging.go:150–165  ·  view source on GitHub ↗
(req *http.Request, httpHeadersToExclude map[string]bool)

Source from the content-addressed store, hash-verified

148}
149
150func dumpRequestHeaders(req *http.Request, httpHeadersToExclude map[string]bool) ([]byte, error) {
151 var b bytes.Buffer
152
153 // In case users initialize the Log middleware using the exported struct, skip the default headers anyway
154 if len(httpHeadersToExclude) == 0 {
155 httpHeadersToExclude = AlwaysExcludedHeaders
156 }
157 // Exclude some headers for security, or just that we don't need them when debugging
158 err := req.Header.WriteSubset(&b, httpHeadersToExclude)
159 if err != nil {
160 return nil, err
161 }
162
163 ret := bytes.ReplaceAll(b.Bytes(), []byte("\r\n"), []byte("; "))
164 return ret, nil
165}

Callers 1

WrapMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected