diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-06-10 10:59:18 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-06-10 10:59:18 +0200 |
commit | c29cace1e8f3260389ea78fa4ef86d80cd5e5275 (patch) | |
tree | 947e4435053998a194caacab99bf614d8fd5bc78 /src/pkg/http/url.go | |
parent | 56135c623a865c501ab31cc940c0e22ece2673f4 (diff) | |
download | golang-c29cace1e8f3260389ea78fa4ef86d80cd5e5275.tar.gz |
Imported Upstream version 2011.06.09upstream-weekly/2011.06.09
Diffstat (limited to 'src/pkg/http/url.go')
-rw-r--r-- | src/pkg/http/url.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pkg/http/url.go b/src/pkg/http/url.go index d7ee14ee8..05b1662d3 100644 --- a/src/pkg/http/url.go +++ b/src/pkg/http/url.go @@ -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 +} |