diff options
| author | Petar Maymounkov <petarm@gmail.com> | 2010-02-22 15:39:30 -0800 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2010-02-22 15:39:30 -0800 |
| commit | 39e91f88582092399910f1d3670cfd8871e2b5e9 (patch) | |
| tree | 658185fac569e1f461a8401179d2a98afdc93e13 /src/pkg/http/request.go | |
| parent | 1a37656b7a5aa97b23ec837825c6b30622f11b2c (diff) | |
| download | go-39e91f88582092399910f1d3670cfd8871e2b5e9.tar.xz | |
http: use RawURL in Request.Write
R=rsc
CC=golang-dev
https://golang.org/cl/217066
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 89a5d837cd..2110dfd525 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) |
