CopyToRequest copies headers from the provided header to the http.Request.
(header http.Header, req *http.Request)
| 46 | |
| 47 | // CopyToRequest copies headers from the provided header to the http.Request. |
| 48 | func CopyToRequest(header http.Header, req *http.Request) { |
| 49 | for key, values := range header { |
| 50 | if len(values) == 0 { |
| 51 | continue |
| 52 | } |
| 53 | |
| 54 | // Keys in http.Header are already canonicalized, so no need for http.CanonicalHeaderKey here |
| 55 | if key == Host { |
| 56 | req.Host = values[0] |
| 57 | } else { |
| 58 | req.Header[key] = append([]string(nil), values...) |
| 59 | } |
| 60 | } |
| 61 | } |
no outgoing calls