本文整理匯總了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")
}
}