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 {
func NewConfig(server, origin string) (config *Config, err error) {
config = new(Config)
config.Version = ProtocolVersionHybi13
config.Location, err = url.ParseRequest(server)
config.Location, err = url.ParseRequestURI(server)
if err != nil {
return
}
config.Origin, err = url.ParseRequest(origin)
config.Origin, err = url.ParseRequestURI(origin)
if err != nil {
return
}
......
......@@ -533,7 +533,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
}
// 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 {
return http.StatusBadRequest, err
}
......@@ -557,7 +557,7 @@ func (c *hixie76ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
} else {
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 {
return http.StatusBadRequest, err
}
......@@ -642,7 +642,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
if req.Header.Get("Connection") != "Upgrade" {
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 {
return http.StatusBadRequest, err
}
......@@ -653,7 +653,7 @@ func (c *hixie75ServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Req
} else {
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 {
return http.StatusBadRequest, err
}
......
......@@ -48,11 +48,11 @@ Sec-WebSocket-Protocol: sample
var err error
config := new(Config)
config.Location, err = url.ParseRequest("ws://example.com/demo")
config.Location, err = url.ParseRequestURI("ws://example.com/demo")
if err != nil {
t.Fatal("location url", err)
}
config.Origin, err = url.ParseRequest("http://example.com")
config.Origin, err = url.ParseRequestURI("http://example.com")
if err != nil {
t.Fatal("origin url", err)
}
......
......@@ -495,7 +495,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
default:
return http.StatusBadRequest, ErrBadWebSocketVersion
}
c.Origin, err = url.ParseRequest(origin)
c.Origin, err = url.ParseRequestURI(origin)
if err != nil {
return http.StatusForbidden, err
}
......@@ -505,7 +505,7 @@ func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Reques
} else {
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 {
return http.StatusBadRequest, err
}
......
......@@ -42,11 +42,11 @@ Sec-WebSocket-Protocol: chat
`))
var err error
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 {
t.Fatal("location url", err)
}
config.Origin, err = url.ParseRequest("http://example.com")
config.Origin, err = url.ParseRequestURI("http://example.com")
if err != nil {
t.Fatal("origin url", err)
}
......@@ -104,11 +104,11 @@ Sec-WebSocket-Protocol: chat
`))
var err error
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 {
t.Fatal("location url", err)
}
config.Origin, err = url.ParseRequest("http://example.com")
config.Origin, err = url.ParseRequestURI("http://example.com")
if err != nil {
t.Fatal("origin url", err)
}
......
......@@ -164,7 +164,7 @@ func TestWithQuery(t *testing.T) {
}
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 {
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