aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/request_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <brad@danga.com>2010-07-14 17:26:14 -0700
committerRuss Cox <rsc@golang.org>2010-07-14 17:26:14 -0700
commit9b64fef71acf71175bc74e2d04ea7fc0a011b03b (patch)
treef3921ff64154fc3d50cbb810e255d10ad44d5634 /src/pkg/http/request_test.go
parente9bcbc539890020668cbd361a0d8edbb8f6ab8a1 (diff)
downloadgo-9b64fef71acf71175bc74e2d04ea7fc0a011b03b.tar.xz
mime/multipart and HTTP multipart/form-data support
Somewhat of a work-in-progress (in that MIME is a large spec), but this is functional and enough for discussion and/or code review. In addition to the unit tests, I've tested with curl and Chrome with a variety of test files, making sure the digests of files are unaltered when read via a multipart Part. R=rsc, adg, dsymonds1, agl1 CC=golang-dev https://golang.org/cl/1681049
Diffstat (limited to 'src/pkg/http/request_test.go')
-rw-r--r--src/pkg/http/request_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/http/request_test.go b/src/pkg/http/request_test.go
index 98d5342bbb..4ba173a986 100644
--- a/src/pkg/http/request_test.go
+++ b/src/pkg/http/request_test.go
@@ -101,6 +101,24 @@ func TestPostContentTypeParsing(t *testing.T) {
}
}
+func TestMultipartReader(t *testing.T) {
+ req := &Request{
+ Method: "POST",
+ Header: stringMap{"Content-Type": `multipart/form-data; boundary="foo123"`},
+ Body: nopCloser{new(bytes.Buffer)},
+ }
+ multipart, err := req.MultipartReader()
+ if multipart == nil {
+ t.Errorf("expected multipart; error: %v", err)
+ }
+
+ req.Header = stringMap{"Content-Type": "text/plain"}
+ multipart, err = req.MultipartReader()
+ if multipart != nil {
+ t.Errorf("unexpected multipart for text/plain")
+ }
+}
+
func TestRedirect(t *testing.T) {
const (
start = "http://codesearch.google.com/"