執行 HTTP Get 請求后,我收到以下錯誤:2015/08/30 16:42:09 Get https://en.wikipedia.org/wiki/List_of_S%26P_500_companies: stopped after 10 redirects在以下代碼中:package mainimport ( "net/http" "log")func main() { response, err := http.Get("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies") if err != nil { log.Fatal(err) }}我知道根據文檔,// Get issues a GET to the specified URL. If the response is one of// the following redirect codes, Get follows the redirect, up to a// maximum of 10 redirects://// 301 (Moved Permanently)// 302 (Found)// 303 (See Other)// 307 (Temporary Redirect)//// An error is returned if there were too many redirects or if there// was an HTTP protocol error. A non-2xx response doesn't cause an// error.我希望有人知道在這種情況下的解決方案是什么。這個簡單的 url 導致十多個重定向似乎很奇怪。讓我覺得在幕后可能還有更多事情發生。
2 回答

守著星空守著你
TA貢獻1799條經驗 獲得超8個贊
我在包含 Wikipedia URL 時遇到了這個問題,%26
因為它們重定向到一個 URL 版本,&
然后 Go 將其編碼為%26
Wikipedia 重定向到的 URL&
和......
奇怪的是,gcc-go
從我的 Arch 盒子中移除(v1.4) 并用go
(v1.5)替換它已經解決了這個問題。
我猜這可以歸結為net/http
v1.4 和 v1.5 之間的變化。
- 2 回答
- 0 關注
- 236 瀏覽
添加回答
舉報
0/150
提交
取消