feat(http): assign customHeaders to the map directly (#5445)

also add skip expr if header key is "Host"

Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
Dwi Siswanto 2024-07-26 22:24:35 +07:00 committed by GitHub
parent 33dbb51505
commit 6d325a4ebe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1083,10 +1083,15 @@ func (request *Request) setCustomHeaders(req *generatedRequest) {
req.rawRequest.Headers[k] = v req.rawRequest.Headers[k] = v
} else { } else {
kk, vv := strings.TrimSpace(k), strings.TrimSpace(v) kk, vv := strings.TrimSpace(k), strings.TrimSpace(v)
req.request.Header.Set(kk, vv) // NOTE(dwisiswant0): Do we really not need to convert it first into
// lowercase?
if kk == "Host" { if kk == "Host" {
req.request.Host = vv req.request.Host = vv
continue
} }
req.request.Header[kk] = []string{vv}
} }
} }
} }