本文整理汇总了Golang中net/http.Response.ProtoAtLeast方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.ProtoAtLeast方法的具体用法?Golang Response.ProtoAtLeast怎么用?Golang Response.ProtoAtLeast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http.Response
的用法示例。
在下文中一共展示了Response.ProtoAtLeast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: prepareResponseHeaders
func prepareResponseHeaders(res *http.Response) {
// remove global hop-by-hop headers.
for _, h := range hopHeaders {
res.Header.Del(h)
}
// remove the Upgrade header and headers referenced in the Connection
// header if HTTP < 1.1 or if Connection header didn't contain "upgrade":
// https://tools.ietf.org/html/rfc7230#section-6.7
if !res.ProtoAtLeast(1, 1) || !isConnectionUpgrade(res.Header) {
res.Header.Del("Upgrade")
// A proxy or gateway MUST parse a received Connection header field before a
// message is forwarded and, for each connection-option in this field, remove
// any header field(s) from the message with the same name as the
// connection-option, and then remove the Connection header field itself (or
// replace it with the intermediary's own connection options for the
// forwarded message): https://tools.ietf.org/html/rfc7230#section-6.1
tokens := strings.Split(res.Header.Get("Connection"), ",")
for _, hdr := range tokens {
res.Header.Del(hdr)
}
res.Header.Del("Connection")
}
}