CopyFromRequest copies specified headers from the http.Request to the provided header.
(req *http.Request, header http.Header, only []string)
| 30 | |
| 31 | // CopyFromRequest copies specified headers from the http.Request to the provided header. |
| 32 | func 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. |
| 48 | func CopyToRequest(header http.Header, req *http.Request) { |