Commit 359f934a authored by David Symonds's avatar David Symonds

go.net: gofix for net/url API changes.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5672082
parent 2e820aa3
...@@ -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.ParseRequestURI(server)
if err != nil { if err != nil {
return return
} }
config.Origin, err = url.ParseRequest(origin) config.Origin, err = url.ParseRequestURI(origin)
if err != nil { if err != nil {
return return
} }
......
...@@ -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.ParseRequestURI(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.ParseRequestURI(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.ParseRequestURI(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.ParseRequestURI(scheme + "://" + req.Host + req.URL.RequestURI())
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
......
...@@ -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.ParseRequestURI("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.ParseRequestURI("http://example.com")
if err != nil { if err != nil {
t.Fatal("origin url", err) t.Fatal("origin url", err)
} }
......
...@@ -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.ParseRequestURI(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.ParseRequestURI(scheme + "://" + req.Host + req.URL.RequestURI())
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
......
...@@ -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.ParseRequestURI("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.ParseRequestURI("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.ParseRequestURI("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.ParseRequestURI("http://example.com")
if err != nil { if err != nil {
t.Fatal("origin url", err) t.Fatal("origin url", err)
} }
......
...@@ -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.ParseRequestURI(fmt.Sprintf("ws://%s/echo?q=v", serverAddr))
if err != nil { if err != nil {
t.Fatal("location url", err) t.Fatal("location url", err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment