mirror of
https://github.com/golang/go
synced 2024-11-22 08:04:39 -07:00
undo CL 4808044 / 1bd754e69ce7
ServeMux depends on having a URL in order to mux. It might be that the right fix is to have CONNECT handlers just not look at URL. ««« original CL description http: do not parse req.URL for CONNECT CONNECT's argument is not a URL. R=golang-dev, bradfitz, rsc CC=golang-dev https://golang.org/cl/4808044 »»» TBR=bradfitz CC=golang-dev https://golang.org/cl/4798046
This commit is contained in:
parent
bf5ec12dd5
commit
17d9093bf2
@ -152,28 +152,6 @@ var reqTests = []reqTest{
|
|||||||
noBody,
|
noBody,
|
||||||
"parse : empty url",
|
"parse : empty url",
|
||||||
},
|
},
|
||||||
|
|
||||||
// CONNECT method.
|
|
||||||
{
|
|
||||||
"CONNECT proxy.example.com:443 HTTP/1.0\r\n" +
|
|
||||||
"Host: proxy.example.com\r\n\r\n",
|
|
||||||
|
|
||||||
&Request{
|
|
||||||
Method: "CONNECT",
|
|
||||||
RawURL: "proxy.example.com:443",
|
|
||||||
URL: nil,
|
|
||||||
Proto: "HTTP/1.0",
|
|
||||||
ProtoMajor: 1,
|
|
||||||
ProtoMinor: 0,
|
|
||||||
Close: false,
|
|
||||||
ContentLength: 0,
|
|
||||||
Host: "proxy.example.com",
|
|
||||||
Form: Values{},
|
|
||||||
},
|
|
||||||
|
|
||||||
noBody,
|
|
||||||
noError,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadRequest(t *testing.T) {
|
func TestReadRequest(t *testing.T) {
|
||||||
|
@ -548,12 +548,9 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) {
|
|||||||
return nil, &badStringError{"malformed HTTP version", req.Proto}
|
return nil, &badStringError{"malformed HTTP version", req.Proto}
|
||||||
}
|
}
|
||||||
|
|
||||||
isConnect := strings.ToUpper(req.Method) == "CONNECT"
|
|
||||||
if !isConnect {
|
|
||||||
if req.URL, err = ParseRequestURL(req.RawURL); err != nil {
|
if req.URL, err = ParseRequestURL(req.RawURL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Subsequent lines: Key: value.
|
// Subsequent lines: Key: value.
|
||||||
mimeHeader, err := tp.ReadMIMEHeader()
|
mimeHeader, err := tp.ReadMIMEHeader()
|
||||||
@ -569,9 +566,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) {
|
|||||||
// GET http://www.google.com/index.html HTTP/1.1
|
// GET http://www.google.com/index.html HTTP/1.1
|
||||||
// Host: doesntmatter
|
// Host: doesntmatter
|
||||||
// the same. In the second case, any Host line is ignored.
|
// the same. In the second case, any Host line is ignored.
|
||||||
if !isConnect {
|
|
||||||
req.Host = req.URL.Host
|
req.Host = req.URL.Host
|
||||||
}
|
|
||||||
if req.Host == "" {
|
if req.Host == "" {
|
||||||
req.Host = req.Header.Get("Host")
|
req.Host = req.Header.Get("Host")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user