Commit 5c3827cb authored by Russ Cox's avatar Russ Cox

http: correct escaping of different parts of URL

Fixes #1076.

R=adg
CC=golang-dev
https://golang.org/cl/2248045
parent 9ff4565e
......@@ -45,7 +45,7 @@ func send(req *Request) (resp *Response, err os.Error) {
if !hasPort(addr) {
addr += ":" + req.URL.Scheme
}
info := req.URL.Userinfo
info := req.URL.RawUserinfo
if len(info) > 0 {
enc := base64.URLEncoding
encoded := make([]byte, enc.EncodedLen(len(info)))
......
......@@ -37,15 +37,15 @@ var reqTests = []reqTest{
Method: "GET",
RawURL: "http://www.techcrunch.com/",
URL: &URL{
Raw: "http://www.techcrunch.com/",
Scheme: "http",
RawPath: "/",
Authority: "www.techcrunch.com",
Userinfo: "",
Host: "www.techcrunch.com",
Path: "/",
RawQuery: "",
Fragment: "",
Raw: "http://www.techcrunch.com/",
Scheme: "http",
RawPath: "/",
RawAuthority: "www.techcrunch.com",
RawUserinfo: "",
Host: "www.techcrunch.com",
Path: "/",
RawQuery: "",
Fragment: "",
},
Proto: "HTTP/1.1",
ProtoMajor: 1,
......
......@@ -191,7 +191,7 @@ func (req *Request) Write(w io.Writer) os.Error {
uri := req.RawURL
if uri == "" {
uri = valueOrDefault(urlEscape(req.URL.Path, false, false), "/")
uri = valueOrDefault(urlEscape(req.URL.Path, encodePath), "/")
if req.URL.RawQuery != "" {
uri += "?" + req.URL.RawQuery
}
......
......@@ -21,15 +21,15 @@ var reqWriteTests = []reqWriteTest{
Method: "GET",
RawURL: "http://www.techcrunch.com/",
URL: &URL{
Raw: "http://www.techcrunch.com/",
Scheme: "http",
RawPath: "http://www.techcrunch.com/",
Authority: "www.techcrunch.com",
Userinfo: "",
Host: "www.techcrunch.com",
Path: "/",
RawQuery: "",
Fragment: "",
Raw: "http://www.techcrunch.com/",
Scheme: "http",
RawPath: "http://www.techcrunch.com/",
RawAuthority: "www.techcrunch.com",
RawUserinfo: "",
Host: "www.techcrunch.com",
Path: "/",
RawQuery: "",
Fragment: "",
},
Proto: "HTTP/1.1",
ProtoMajor: 1,
......
This diff is collapsed.
This diff is collapsed.
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