CopyAll copies all headers from one header to another.
(from, to http.Header, overwrite bool)
| 16 | |
| 17 | // CopyAll copies all headers from one header to another. |
| 18 | func 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. |
| 32 | func CopyFromRequest(req *http.Request, header http.Header, only []string) { |
no outgoing calls