我有一个使用 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")
}
UYOU
相关分类