type Request struct {
// ...
// The protocol version for incoming server requests.
//
// For client requests, these fields are ignored. The HTTP
// client code always uses either HTTP/1.1 or HTTP/2.
// See the docs on Transport for details.
Proto string // "HTTP/1.0"
ProtoMajor int // 1
ProtoMinor int // 0
// ...
}
1条答案
按热度按时间7z5jn7bk1#
http.Request
包含协议版本的字段:字符串
您可以简单地检查
ProtoMajor
字段是否为2
。