Merge pull request #239 from tufanbarisyildirim/feature/passing-host-header

a workaround for golang limitation of passing Host in header
pull/251/head
Hunter Long 2019-09-04 12:22:39 -07:00 committed by GitHub
commit 23b6c39623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -301,7 +301,11 @@ func HttpRequest(url, method string, content interface{}, headers []string, body
keyVal := strings.Split(h, "=")
if len(keyVal) == 2 {
if keyVal[0] != "" && keyVal[1] != "" {
req.Header.Set(keyVal[0], keyVal[1])
if strings.ToLower(keyVal[0]) == "host" {
req.Host = strings.TrimSpace(keyVal[1])
} else {
req.Header.Set(keyVal[0], keyVal[1])
}
}
}
}