OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package websocket | 5 package websocket |
6 | 6 |
7 // This file implements a protocol of hybi draft. | 7 // This file implements a protocol of hybi draft. |
8 // http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 | 8 // http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 |
9 | 9 |
10 import ( | 10 import ( |
11 "bufio" | 11 "bufio" |
12 "bytes" | 12 "bytes" |
13 "crypto/rand" | 13 "crypto/rand" |
14 "crypto/sha1" | 14 "crypto/sha1" |
15 "encoding/base64" | 15 "encoding/base64" |
16 "encoding/binary" | 16 "encoding/binary" |
17 "fmt" | 17 "fmt" |
18 "http" | |
19 "io" | 18 "io" |
20 "io/ioutil" | 19 "io/ioutil" |
| 20 "net/http" |
| 21 "net/url" |
21 "strings" | 22 "strings" |
22 "url" | |
23 ) | 23 ) |
24 | 24 |
25 const ( | 25 const ( |
26 websocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" | 26 websocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" |
27 | 27 |
28 closeStatusNormal = 1000 | 28 closeStatusNormal = 1000 |
29 closeStatusGoingAway = 1001 | 29 closeStatusGoingAway = 1001 |
30 closeStatusProtocolError = 1002 | 30 closeStatusProtocolError = 1002 |
31 closeStatusUnsupportedData = 1003 | 31 closeStatusUnsupportedData = 1003 |
32 closeStatusFrameTooLarge = 1004 | 32 closeStatusFrameTooLarge = 1004 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 540 } |
541 | 541 |
542 func (c *hybiServerHandshaker) NewServerConn(buf *bufio.ReadWriter, rwc io.ReadW
riteCloser, request *http.Request) *Conn { | 542 func (c *hybiServerHandshaker) NewServerConn(buf *bufio.ReadWriter, rwc io.ReadW
riteCloser, request *http.Request) *Conn { |
543 return newHybiServerConn(c.Config, buf, rwc, request) | 543 return newHybiServerConn(c.Config, buf, rwc, request) |
544 } | 544 } |
545 | 545 |
546 // newHybiServerConn returns a new WebSocket connection speaking hybi draft prot
ocol. | 546 // newHybiServerConn returns a new WebSocket connection speaking hybi draft prot
ocol. |
547 func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCl
oser, request *http.Request) *Conn { | 547 func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCl
oser, request *http.Request) *Conn { |
548 return newHybiConn(config, buf, rwc, request) | 548 return newHybiConn(config, buf, rwc, request) |
549 } | 549 } |
OLD | NEW |