aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/response.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http/response.go')
-rw-r--r--src/net/http/response.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/net/http/response.go b/src/net/http/response.go
index 72812f0642..b95abae646 100644
--- a/src/net/http/response.go
+++ b/src/net/http/response.go
@@ -352,10 +352,16 @@ func (r *Response) bodyIsWritable() bool {
return ok
}
-// isProtocolSwitch reports whether r is a response to a successful
-// protocol upgrade.
+// isProtocolSwitch reports whether the response code and header
+// indicate a successful protocol upgrade response.
func (r *Response) isProtocolSwitch() bool {
- return r.StatusCode == StatusSwitchingProtocols &&
- r.Header.Get("Upgrade") != "" &&
- httpguts.HeaderValuesContainsToken(r.Header["Connection"], "Upgrade")
+ return isProtocolSwitchResponse(r.StatusCode, r.Header)
+}
+
+// isProtocolSwitchResponse reports whether the response code and
+// response header indicate a successful protocol upgrade response.
+func isProtocolSwitchResponse(code int, h Header) bool {
+ return code == StatusSwitchingProtocols &&
+ h.Get("Upgrade") != "" &&
+ httpguts.HeaderValuesContainsToken(h["Connection"], "Upgrade")
}