Upgrade upgrades the HTTP server connection to the WebSocket protocol. Deprecated: Use websocket.Upgrader instead. Upgrade does not perform origin checking. The application is responsible for checking the Origin header before calling Upgrade. An example implementation of the same origin policy che
(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int)
| 295 | // error of type HandshakeError. Applications should handle this error by |
| 296 | // replying to the client with an HTTP error response. |
| 297 | func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) { |
| 298 | u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize} |
| 299 | u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) { |
| 300 | // don't return errors to maintain backwards compatibility |
| 301 | } |
| 302 | u.CheckOrigin = func(r *http.Request) bool { |
| 303 | // allow all connections by default |
| 304 | return true |
| 305 | } |
| 306 | return u.Upgrade(w, r, responseHeader) |
| 307 | } |
| 308 | |
| 309 | // Subprotocols returns the subprotocols requested by the client in the |
| 310 | // Sec-Websocket-Protocol header. |