vendor/github.com/gorilla/websocket/server.go
changeset 251 1c52a0eeb952
parent 242 2a9ec03fe5a1
child 260 445e01aede7e
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
    25 // WebSocket connection.
    25 // WebSocket connection.
    26 type Upgrader struct {
    26 type Upgrader struct {
    27 	// HandshakeTimeout specifies the duration for the handshake to complete.
    27 	// HandshakeTimeout specifies the duration for the handshake to complete.
    28 	HandshakeTimeout time.Duration
    28 	HandshakeTimeout time.Duration
    29 
    29 
    30 	// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
    30 	// ReadBufferSize and WriteBufferSize specify I/O buffer sizes in bytes. If a buffer
    31 	// size is zero, then buffers allocated by the HTTP server are used. The
    31 	// size is zero, then buffers allocated by the HTTP server are used. The
    32 	// I/O buffer sizes do not limit the size of the messages that can be sent
    32 	// I/O buffer sizes do not limit the size of the messages that can be sent
    33 	// or received.
    33 	// or received.
    34 	ReadBufferSize, WriteBufferSize int
    34 	ReadBufferSize, WriteBufferSize int
    35 
    35 
   151 		return u.returnError(w, r, http.StatusForbidden, "websocket: request origin not allowed by Upgrader.CheckOrigin")
   151 		return u.returnError(w, r, http.StatusForbidden, "websocket: request origin not allowed by Upgrader.CheckOrigin")
   152 	}
   152 	}
   153 
   153 
   154 	challengeKey := r.Header.Get("Sec-Websocket-Key")
   154 	challengeKey := r.Header.Get("Sec-Websocket-Key")
   155 	if challengeKey == "" {
   155 	if challengeKey == "" {
   156 		return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-WebSocket-Key' header is missing or blank")
   156 		return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'Sec-WebSocket-Key' header is missing or blank")
   157 	}
   157 	}
   158 
   158 
   159 	subprotocol := u.selectSubprotocol(r, responseHeader)
   159 	subprotocol := u.selectSubprotocol(r, responseHeader)
   160 
   160 
   161 	// Negotiate PMCE
   161 	// Negotiate PMCE