Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
net
Commits
359f934a
Commit
359f934a
authored
Feb 18, 2012
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go.net: gofix for net/url API changes.
R=golang-dev, r CC=golang-dev
https://golang.org/cl/5672082
parent
2e820aa3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
15 deletions
+15
-15
client.go
websocket/client.go
+2
-2
hixie.go
websocket/hixie.go
+4
-4
hixie_test.go
websocket/hixie_test.go
+2
-2
hybi.go
websocket/hybi.go
+2
-2
hybi_test.go
websocket/hybi_test.go
+4
-4
websocket_test.go
websocket/websocket_test.go
+1
-1
No files found.
websocket/client.go
View file @
359f934a
...
@@ -26,11 +26,11 @@ func (e *DialError) Error() string {
...
@@ -26,11 +26,11 @@ func (e *DialError) Error() string {
func
NewConfig
(
server
,
origin
string
)
(
config
*
Config
,
err
error
)
{
func
NewConfig
(
server
,
origin
string
)
(
config
*
Config
,
err
error
)
{
config
=
new
(
Config
)
config
=
new
(
Config
)
config
.
Version
=
ProtocolVersionHybi13
config
.
Version
=
ProtocolVersionHybi13
config
.
Location
,
err
=
url
.
ParseRequest
(
server
)
config
.
Location
,
err
=
url
.
ParseRequest
URI
(
server
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
config
.
Origin
,
err
=
url
.
ParseRequest
(
origin
)
config
.
Origin
,
err
=
url
.
ParseRequest
URI
(
origin
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
...
websocket/hixie.go
View file @
359f934a
...
@@ -533,7 +533,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
...
@@ -533,7 +533,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
}
}
// TODO(ukai): check Host
// TODO(ukai): check Host
c
.
Origin
,
err
=
url
.
ParseRequest
(
req
.
Header
.
Get
(
"Origin"
))
c
.
Origin
,
err
=
url
.
ParseRequest
URI
(
req
.
Header
.
Get
(
"Origin"
))
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusBadRequest
,
err
return
http
.
StatusBadRequest
,
err
}
}
...
@@ -557,7 +557,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
...
@@ -557,7 +557,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
}
else
{
}
else
{
scheme
=
"ws"
scheme
=
"ws"
}
}
c
.
Location
,
err
=
url
.
ParseRequest
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
c
.
Location
,
err
=
url
.
ParseRequest
URI
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusBadRequest
,
err
return
http
.
StatusBadRequest
,
err
}
}
...
@@ -642,7 +642,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
...
@@ -642,7 +642,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
if
req
.
Header
.
Get
(
"Connection"
)
!=
"Upgrade"
{
if
req
.
Header
.
Get
(
"Connection"
)
!=
"Upgrade"
{
return
http
.
StatusBadRequest
,
ErrNotWebSocket
return
http
.
StatusBadRequest
,
ErrNotWebSocket
}
}
c
.
Origin
,
err
=
url
.
ParseRequest
(
strings
.
TrimSpace
(
req
.
Header
.
Get
(
"Origin"
)))
c
.
Origin
,
err
=
url
.
ParseRequest
URI
(
strings
.
TrimSpace
(
req
.
Header
.
Get
(
"Origin"
)))
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusBadRequest
,
err
return
http
.
StatusBadRequest
,
err
}
}
...
@@ -653,7 +653,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
...
@@ -653,7 +653,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
}
else
{
}
else
{
scheme
=
"ws"
scheme
=
"ws"
}
}
c
.
Location
,
err
=
url
.
ParseRequest
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
c
.
Location
,
err
=
url
.
ParseRequest
URI
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusBadRequest
,
err
return
http
.
StatusBadRequest
,
err
}
}
...
...
websocket/hixie_test.go
View file @
359f934a
...
@@ -48,11 +48,11 @@ Sec-WebSocket-Protocol: sample
...
@@ -48,11 +48,11 @@ Sec-WebSocket-Protocol: sample
var
err
error
var
err
error
config
:=
new
(
Config
)
config
:=
new
(
Config
)
config
.
Location
,
err
=
url
.
ParseRequest
(
"ws://example.com/demo"
)
config
.
Location
,
err
=
url
.
ParseRequest
URI
(
"ws://example.com/demo"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"location url"
,
err
)
t
.
Fatal
(
"location url"
,
err
)
}
}
config
.
Origin
,
err
=
url
.
ParseRequest
(
"http://example.com"
)
config
.
Origin
,
err
=
url
.
ParseRequest
URI
(
"http://example.com"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"origin url"
,
err
)
t
.
Fatal
(
"origin url"
,
err
)
}
}
...
...
websocket/hybi.go
View file @
359f934a
...
@@ -495,7 +495,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
...
@@ -495,7 +495,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
default
:
default
:
return
http
.
StatusBadRequest
,
ErrBadWebSocketVersion
return
http
.
StatusBadRequest
,
ErrBadWebSocketVersion
}
}
c
.
Origin
,
err
=
url
.
ParseRequest
(
origin
)
c
.
Origin
,
err
=
url
.
ParseRequest
URI
(
origin
)
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusForbidden
,
err
return
http
.
StatusForbidden
,
err
}
}
...
@@ -505,7 +505,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
...
@@ -505,7 +505,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
}
else
{
}
else
{
scheme
=
"ws"
scheme
=
"ws"
}
}
c
.
Location
,
err
=
url
.
ParseRequest
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
c
.
Location
,
err
=
url
.
ParseRequest
URI
(
scheme
+
"://"
+
req
.
Host
+
req
.
URL
.
RequestURI
())
if
err
!=
nil
{
if
err
!=
nil
{
return
http
.
StatusBadRequest
,
err
return
http
.
StatusBadRequest
,
err
}
}
...
...
websocket/hybi_test.go
View file @
359f934a
...
@@ -42,11 +42,11 @@ Sec-WebSocket-Protocol: chat
...
@@ -42,11 +42,11 @@ Sec-WebSocket-Protocol: chat
`
))
`
))
var
err
error
var
err
error
config
:=
new
(
Config
)
config
:=
new
(
Config
)
config
.
Location
,
err
=
url
.
ParseRequest
(
"ws://server.example.com/chat"
)
config
.
Location
,
err
=
url
.
ParseRequest
URI
(
"ws://server.example.com/chat"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"location url"
,
err
)
t
.
Fatal
(
"location url"
,
err
)
}
}
config
.
Origin
,
err
=
url
.
ParseRequest
(
"http://example.com"
)
config
.
Origin
,
err
=
url
.
ParseRequest
URI
(
"http://example.com"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"origin url"
,
err
)
t
.
Fatal
(
"origin url"
,
err
)
}
}
...
@@ -104,11 +104,11 @@ Sec-WebSocket-Protocol: chat
...
@@ -104,11 +104,11 @@ Sec-WebSocket-Protocol: chat
`
))
`
))
var
err
error
var
err
error
config
:=
new
(
Config
)
config
:=
new
(
Config
)
config
.
Location
,
err
=
url
.
ParseRequest
(
"ws://server.example.com/chat"
)
config
.
Location
,
err
=
url
.
ParseRequest
URI
(
"ws://server.example.com/chat"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"location url"
,
err
)
t
.
Fatal
(
"location url"
,
err
)
}
}
config
.
Origin
,
err
=
url
.
ParseRequest
(
"http://example.com"
)
config
.
Origin
,
err
=
url
.
ParseRequest
URI
(
"http://example.com"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"origin url"
,
err
)
t
.
Fatal
(
"origin url"
,
err
)
}
}
...
...
websocket/websocket_test.go
View file @
359f934a
...
@@ -164,7 +164,7 @@ func TestWithQuery(t *testing.T) {
...
@@ -164,7 +164,7 @@ func TestWithQuery(t *testing.T) {
}
}
config
:=
newConfig
(
t
,
"/echo"
)
config
:=
newConfig
(
t
,
"/echo"
)
config
.
Location
,
err
=
url
.
ParseRequest
(
fmt
.
Sprintf
(
"ws://%s/echo?q=v"
,
serverAddr
))
config
.
Location
,
err
=
url
.
ParseRequest
URI
(
fmt
.
Sprintf
(
"ws://%s/echo?q=v"
,
serverAddr
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
"location url"
,
err
)
t
.
Fatal
(
"location url"
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment