parseRequestHeaders will take user-provided header values as strings "Content-Type: application/json" and create a http.Header object.
(values []string)
| 14 | // parseRequestHeaders will take user-provided header values as strings "Content-Type: application/json" and create |
| 15 | // a http.Header object. |
| 16 | func parseRequestHeaders(values []string) http.Header { |
| 17 | headers := make(http.Header) |
| 18 | for _, valuePair := range values { |
| 19 | header, value, found := strings.Cut(valuePair, ":") |
| 20 | if found { |
| 21 | headers.Add(strings.TrimSpace(header), strings.TrimSpace(value)) |
| 22 | } |
| 23 | } |
| 24 | return headers |
| 25 | } |
| 26 | |
| 27 | // bracketBareIPv6 wraps bare IPv6 addresses in a URL with square brackets. |
| 28 | // Go 1.26 tightened net/url parsing to strictly require RFC 3986 bracket syntax |