diff options
author | Petar Maymounkov <petarm@gmail.com> | 2010-02-22 15:39:30 -0800 |
---|---|---|
committer | Petar Maymounkov <petarm@gmail.com> | 2010-02-22 15:39:30 -0800 |
commit | 45e762795a63dc90941f9165643baca80809a8d5 (patch) | |
tree | 57be88af522eced0e1328931ed6bbf42e2dbfb15 /src/pkg/http/request.go | |
parent | ec2af12ed506afad3fc31dbe6779892f7ceffff1 (diff) | |
download | golang-45e762795a63dc90941f9165643baca80809a8d5.tar.gz |
http: use RawURL in Request.Write
R=rsc
CC=golang-dev
http://codereview.appspot.com/217066
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/http/request.go')
-rw-r--r-- | src/pkg/http/request.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pkg/http/request.go b/src/pkg/http/request.go index 89a5d837c..2110dfd52 100644 --- a/src/pkg/http/request.go +++ b/src/pkg/http/request.go @@ -152,7 +152,7 @@ const defaultUserAgent = "Go http package" // Write writes an HTTP/1.1 request -- header and body -- in wire format. // This method consults the following fields of req: // Host -// URL +// RawURL, if non-empty, or else URL // Method (defaults to "GET") // UserAgent (defaults to defaultUserAgent) // Referer @@ -167,9 +167,12 @@ func (req *Request) Write(w io.Writer) os.Error { host = req.URL.Host } - uri := valueOrDefault(urlEscape(req.URL.Path, false), "/") - if req.URL.RawQuery != "" { - uri += "?" + req.URL.RawQuery + uri := req.RawURL + if uri == "" { + uri = valueOrDefault(urlEscape(req.URL.Path, false), "/") + if req.URL.RawQuery != "" { + uri += "?" + req.URL.RawQuery + } } fmt.Fprintf(w, "%s %s HTTP/1.1\r\n", valueOrDefault(req.Method, "GET"), uri) |