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

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

如何在客戶端和服務器中使用 HTTP/1.x

如何在客戶端和服務器中使用 HTTP/1.x

Go
交互式愛情 2023-06-05 08:58:05
我有一個使用 HTTP/2 工作的基本客戶端和服務器實現。我想測試服務器是否也適用于 HTTP/1。有什么方法可以將協議從 HTTP/2 更改為 HTTP/1.x?客戶端代碼:func main() {  host = "https://127.0.0.1:8080"  client = http.Client{    // InsecureTLSDial is temporary and will likely be    // replaced by a different API later.    Transport: &http2.Transport{        TLSClientConfig: &tls.Config{            InsecureSkipVerify: true,        },    },  }  // further functionality}服務器代碼:func main() {    var srv http.Server    srv.Addr = ":8080"    // Set Routes    routes()    // Start server    srv.ListenAndServeTLS("certs/localhost.cert", "certs/localhost.key")}
查看完整描述

1 回答

?
UYOU

TA貢獻1878條經驗 獲得超4個贊

我找到了一個簡單的解決方案。


客戶端的變化


Transport: &http2.Transport{

    TLSClientConfig: &tls.Config{

        InsecureSkipVerify: true,

    },

},

經過


Transport: &http.Transport{

        TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),

        TLSClientConfig: &tls.Config{

            InsecureSkipVerify: true,

        },

    },


查看完整回答
反對 回復 2023-06-05
  • 1 回答
  • 0 關注
  • 209 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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