urlString returns a valid string given a URL. This function is necessary because the String method of URL doesn't correctly handle URLs with non-empty Opaque values. See http://code.google.com/p/go/issues/detail?id=4860.
(u *url.URL)
| 109 | // the String method of URL doesn't correctly handle URLs with non-empty Opaque values. |
| 110 | // See http://code.google.com/p/go/issues/detail?id=4860. |
| 111 | func urlString(u *url.URL) string { |
| 112 | if u.Opaque == "" || strings.HasPrefix(u.Opaque, "//") { |
| 113 | return u.String() |
| 114 | } |
| 115 | aux := *u |
| 116 | aux.Opaque = "//" + aux.Host + aux.Opaque |
| 117 | return aux.String() |
| 118 | } |
| 119 | |
| 120 | // RoundTrip issues a single HTTP request and returns its response. Per the |
| 121 | // http.RoundTripper interface, RoundTrip only returns an error if there |