Skip to content

Commit ab5b3a6

Browse files
committed
Improve server error messages
Update the error messages for missing 'Connection: upgrade' and 'Upgrade: websocket' tokens to indicate that the header might not be present. The previous error message implied that the header is present, but has the wrong value. This leads to some confusion for those debugging connection problems.
1 parent 1f87405 commit ab5b3a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
9898
}
9999

100100
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
101-
return u.returnError(w, r, http.StatusBadRequest, "websocket: connection header != upgrade")
101+
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find connection header with token 'upgrade'")
102102
}
103103

104104
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
105-
return u.returnError(w, r, http.StatusBadRequest, "websocket: upgrade != websocket")
105+
return u.returnError(w, r, http.StatusBadRequest, "websocket: could not find upgrade header with token 'websocket'")
106106
}
107107

108108
checkOrigin := u.CheckOrigin

0 commit comments

Comments
 (0)