亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

維基百科網址在 10 次重定向錯誤 GoLang 后停止

維基百科網址在 10 次重定向錯誤 GoLang 后停止

Go
神不在的星期二 2021-11-01 17:09:21
執行 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 將其編碼為%26Wikipedia 重定向到的 URL&和......

奇怪的是,gcc-go從我的 Arch 盒子中移除(v1.4) 并用go(v1.5)替換它已經解決了這個問題。

我猜這可以歸結為net/httpv1.4 和 v1.5 之間的變化。


查看完整回答
反對 回復 2021-11-01
  • 2 回答
  • 0 關注
  • 236 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號