MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / CopyAll

Function CopyAll

httpheaders/copy.go:18–29  ·  view source on GitHub ↗

CopyAll copies all headers from one header to another.

(from, to http.Header, overwrite bool)

Source from the content-addressed store, hash-verified

16
17// CopyAll copies all headers from one header to another.
18func CopyAll(from, to http.Header, overwrite bool) {
19 for key, values := range from {
20 // Keys in http.Header are already canonicalized, so no need for http.CanonicalHeaderKey here
21 if !overwrite && len(to.Values(key)) > 0 {
22 continue
23 }
24
25 if len(values) > 0 {
26 to[key] = append([]string(nil), values...)
27 }
28 }
29}
30
31// CopyFromRequest copies specified headers from the http.Request to the provided header.
32func CopyFromRequest(req *http.Request, header http.Header, only []string) {

Callers 6

TestCopyAllFunction · 0.92
handlerMethod · 0.92
startMethod · 0.92
GETMethod · 0.92
executeMethod · 0.92
flushHeadersMethod · 0.92

Calls

no outgoing calls

Tested by 3

TestCopyAllFunction · 0.74
handlerMethod · 0.74
executeMethod · 0.74