@@ -76,12 +76,12 @@ func verifyClientRequest(w http.ResponseWriter, r *http.Request) error {
76
76
}
77
77
78
78
// Accept accepts a WebSocket handshake from a client and upgrades the
79
- // the connection to WebSocket.
79
+ // the connection to a WebSocket.
80
80
//
81
81
// Accept will reject the handshake if the Origin domain is not the same as the Host unless
82
82
// the InsecureSkipVerify option is set.
83
83
//
84
- // The returned connection will be bound by r.Context(). Use c .Context() to change
84
+ // The returned connection will be bound by r.Context(). Use conn .Context() to change
85
85
// the bounding context.
86
86
func Accept (w http.ResponseWriter , r * http.Request , opts AcceptOptions ) (* Conn , error ) {
87
87
c , err := accept (w , r , opts )
@@ -107,15 +107,15 @@ func accept(w http.ResponseWriter, r *http.Request, opts AcceptOptions) (*Conn,
107
107
108
108
hj , ok := w .(http.Hijacker )
109
109
if ! ok {
110
- err = xerrors .New ("response writer must implement http.Hijacker" )
110
+ err = xerrors .New ("passed ResponseWriter does not implement http.Hijacker" )
111
111
http .Error (w , http .StatusText (http .StatusInternalServerError ), http .StatusInternalServerError )
112
112
return nil , err
113
113
}
114
114
115
115
w .Header ().Set ("Upgrade" , "websocket" )
116
116
w .Header ().Set ("Connection" , "Upgrade" )
117
117
118
- handleKey (w , r )
118
+ handleSecWebSocketKey (w , r )
119
119
120
120
subproto := selectSubprotocol (r , opts .Subprotocols )
121
121
if subproto != "" {
@@ -163,7 +163,7 @@ func selectSubprotocol(r *http.Request, subprotocols []string) string {
163
163
164
164
var keyGUID = []byte ("258EAFA5-E914-47DA-95CA-C5AB0DC85B11" )
165
165
166
- func handleKey (w http.ResponseWriter , r * http.Request ) {
166
+ func handleSecWebSocketKey (w http.ResponseWriter , r * http.Request ) {
167
167
key := r .Header .Get ("Sec-WebSocket-Key" )
168
168
h := sha1 .New ()
169
169
h .Write ([]byte (key ))
@@ -185,5 +185,5 @@ func authenticateOrigin(r *http.Request) error {
185
185
if strings .EqualFold (u .Host , r .Host ) {
186
186
return nil
187
187
}
188
- return xerrors .Errorf ("request origin %q is not authorized for host %q" , origin , r .Host )
188
+ return xerrors .Errorf ("request Origin %q is not authorized for Host %q" , origin , r .Host )
189
189
}
0 commit comments