a workaroung for golang limitation of passing Host in header

pull/239/head
Tufan Baris Yildirim 2019-09-04 21:38:56 +03:00
parent a19b5dcac8
commit 4f86749b64
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])
}
}
}
}