第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么 httputil.NewSingleHostReverseProxy

為什么 httputil.NewSingleHostReverseProxy

Go
繁星點(diǎn)點(diǎn)滴滴 2021-10-25 18:19:50
在下面的例子中:package mainimport (    "fmt"    "log"    "net/http"    "net/http/httputil"    "net/url")func main() {    p := new(Proxy)    //host := "www.google.com" // WORKS AS EXPECTED    host := "www.apple.com" // GIVES AN ERROR    u, err := url.Parse(fmt.Sprintf("http://%v/", host))    if err != nil {        log.Printf("Error parsing URL")    }    p.proxy = httputil.NewSingleHostReverseProxy(u)    http.Handle("/", p)    log.Fatal(http.ListenAndServe("localhost:8000", nil))}type Proxy struct {    proxy *httputil.ReverseProxy}func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {    p.proxy.ServeHTTP(w, r)}將 Chrome 指向“l(fā)ocalhost:8000”時(shí),將“www.google.com”與“www.apple.com”交換會(huì)導(dǎo)致此錯(cuò)誤:無(wú)效的網(wǎng)址請(qǐng)求的 URL“/”無(wú)效。參考 #9.a61a32b8.1438231668.41733295做更多的挖掘,對(duì)于 www.apple.com,我得到:?  ~  curl --ipv4 -v localhost:8000< HTTP/1.1 400 Bad Request< Content-Length: 194< Content-Type: text/html< Date: Thu, 30 Jul 2015 05:20:38 GMT< Expires: Thu, 30 Jul 2015 05:20:38 GMT< Mime-Version: 1.0* Server AkamaiGHost is not blacklisted< Server: AkamaiGHost< <HTML><HEAD><TITLE>Invalid URL</TITLE></HEAD><BODY><H1>Invalid URL</H1>The requested URL "&#47;", is invalid.<p>Reference&#32;&#35;9&#46;65b454b8&#46;1438233638&#46;1f1b8a40</BODY></HTML>* Connection #0 to host localhost left intact對(duì)于 www.google.com:?  ~  curl --ipv4 -v localhost:8000< HTTP/1.1 302 Found< Alternate-Protocol: 80:quic,p=0< Cache-Control: private< Content-Length: 219< Content-Type: text/html; charset=UTF-8< Date: Thu, 30 Jul 2015 05:03:16 GMT< Location: http://www.google.com/* Server sffe is not blacklisted< Server: sffe< X-Content-Type-Options: nosniff< X-Xss-Protection: 1; mode=block< <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"><TITLE>302 Moved</TITLE></HEAD><BODY><H1>302 Moved</H1>The document has moved<A HREF="http://www.google.com/">here</A>.</BODY></HTML>* Connection #0 to host localhost left intact
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 273 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)