diff options
| author | Russ Cox <rsc@golang.org> | 2011-09-06 12:24:24 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-09-06 12:24:24 -0400 |
| commit | 686181edfed0f738fe6aafe76fafded9d0be155b (patch) | |
| tree | 765cb7944dc64b1bd5d8b2e1c075952240cae72c /src/pkg/http | |
| parent | 5ddf6255a13c5a23663ca49db2d038c6530cb7a1 (diff) | |
| download | go-686181edfed0f738fe6aafe76fafded9d0be155b.tar.xz | |
url: handle ; in ParseQuery
Most web frameworks allow ; as a synonym for &,
following a recommendation in some versions of
the HTML specification. Do the same.
Remove overuse of Split.
Move ParseQuery tests from package http to package url.
Fixes #2210.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4973062
Diffstat (limited to 'src/pkg/http')
| -rw-r--r-- | src/pkg/http/request_test.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/pkg/http/request_test.go b/src/pkg/http/request_test.go index 869cd57b69..175d6f170b 100644 --- a/src/pkg/http/request_test.go +++ b/src/pkg/http/request_test.go @@ -20,57 +20,6 @@ import ( "url" ) -type stringMultimap map[string][]string - -type parseTest struct { - query string - out stringMultimap -} - -var parseTests = []parseTest{ - { - query: "a=1&b=2", - out: stringMultimap{"a": []string{"1"}, "b": []string{"2"}}, - }, - { - query: "a=1&a=2&a=banana", - out: stringMultimap{"a": []string{"1", "2", "banana"}}, - }, - { - query: "ascii=%3Ckey%3A+0x90%3E", - out: stringMultimap{"ascii": []string{"<key: 0x90>"}}, - }, -} - -func TestParseForm(t *testing.T) { - for i, test := range parseTests { - form, err := url.ParseQuery(test.query) - if err != nil { - t.Errorf("test %d: Unexpected error: %v", i, err) - continue - } - if len(form) != len(test.out) { - t.Errorf("test %d: len(form) = %d, want %d", i, len(form), len(test.out)) - } - for k, evs := range test.out { - vs, ok := form[k] - if !ok { - t.Errorf("test %d: Missing key %q", i, k) - continue - } - if len(vs) != len(evs) { - t.Errorf("test %d: len(form[%q]) = %d, want %d", i, k, len(vs), len(evs)) - continue - } - for j, ev := range evs { - if v := vs[j]; v != ev { - t.Errorf("test %d: form[%q][%d] = %q, want %q", i, k, j, v, ev) - } - } - } - } -} - func TestQuery(t *testing.T) { req := &Request{Method: "GET"} req.URL, _ = url.Parse("http://www.google.com/search?q=foo&q=bar") |
