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

Function CopyFromRequest

httpheaders/copy.go:32–45  ·  view source on GitHub ↗

CopyFromRequest copies specified headers from the http.Request to the provided header.

(req *http.Request, header http.Header, only []string)

Source from the content-addressed store, hash-verified

30
31// CopyFromRequest copies specified headers from the http.Request to the provided header.
32func CopyFromRequest(req *http.Request, header http.Header, only []string) {
33 for _, key := range only {
34 key = http.CanonicalHeaderKey(key)
35
36 if key == Host {
37 header.Set(key, req.Host)
38 continue
39 }
40
41 if values := req.Header[key]; len(values) > 0 {
42 header[key] = append([]string(nil), values...)
43 }
44 }
45}
46
47// CopyToRequest copies headers from the provided header to the http.Request.
48func CopyToRequest(header http.Header, req *http.Request) {

Callers 2

TestCopyFromRequestFunction · 0.92

Calls 1

SetMethod · 0.45

Tested by 1

TestCopyFromRequestFunction · 0.74