summaryrefslogtreecommitdiff
path: root/src/pkg/http/url.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/http/url.go')
-rw-r--r--src/pkg/http/url.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/pkg/http/url.go b/src/pkg/http/url.go
index 0fc0cb2d7..05b1662d3 100644
--- a/src/pkg/http/url.go
+++ b/src/pkg/http/url.go
@@ -449,7 +449,7 @@ func ParseURLReference(rawurlref string) (url *URL, err os.Error) {
//
// There are redundant fields stored in the URL structure:
// the String method consults Scheme, Path, Host, RawUserinfo,
-// RawQuery, and Fragment, but not Raw, RawPath or Authority.
+// RawQuery, and Fragment, but not Raw, RawPath or RawAuthority.
func (url *URL) String() string {
result := ""
if url.Scheme != "" {
@@ -486,10 +486,14 @@ func (url *URL) String() string {
return result
}
-// EncodeQuery encodes the query represented as a multimap.
-func EncodeQuery(m map[string][]string) string {
- parts := make([]string, 0, len(m)) // will be large enough for most uses
- for k, vs := range m {
+// Encode encodes the values into ``URL encoded'' form.
+// e.g. "foo=bar&bar=baz"
+func (v Values) Encode() string {
+ if v == nil {
+ return ""
+ }
+ parts := make([]string, 0, len(v)) // will be large enough for most uses
+ for k, vs := range v {
prefix := URLEscape(k) + "="
for _, v := range vs {
parts = append(parts, prefix+URLEscape(v))
@@ -593,3 +597,9 @@ func (base *URL) ResolveReference(ref *URL) *URL {
url.Raw = url.String()
return url
}
+
+// Query parses RawQuery and returns the corresponding values.
+func (u *URL) Query() Values {
+ v, _ := ParseQuery(u.RawQuery)
+ return v
+}