在Go中做了一個簡單的HTTP GET
client:=&http.Client() req,_:=http.NewRequest("GET",url,nil) res,_:=client.Do(req)
通過req.Header.Set("key","value")是可以設置各種頭,但是host這么設置無效
## 解決
host不能通過set方法設置
需要這樣設置:
req.Host = "hostname"
在Go中做了一個簡單的HTTP GET
client:=&http.Client() req,_:=http.NewRequest("GET",url,nil) res,_:=client.Do(req)
通過req.Header.Set("key","value")是可以設置各種頭,但是host這么設置無效
## 解決
host不能通過set方法設置
需要這樣設置:
req.Host = "hostname"
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。