LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package http_test | 5 package http_test |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 . "http" | 10 . "http" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 w.WriteHeader(StatusSeeOther) | 155 w.WriteHeader(StatusSeeOther) |
156 case "/foo/": | 156 case "/foo/": |
157 fmt.Fprintf(w, "foo") | 157 fmt.Fprintf(w, "foo") |
158 default: | 158 default: |
159 w.WriteHeader(StatusBadRequest) | 159 w.WriteHeader(StatusBadRequest) |
160 } | 160 } |
161 })) | 161 })) |
162 defer ts.Close() | 162 defer ts.Close() |
163 | 163 |
164 var end = regexp.MustCompile("/foo/$") | 164 var end = regexp.MustCompile("/foo/$") |
165 » r, url, err := Get(ts.URL) | 165 » r, err := Get(ts.URL) |
166 if err != nil { | 166 if err != nil { |
167 t.Fatal(err) | 167 t.Fatal(err) |
168 } | 168 } |
169 r.Body.Close() | 169 r.Body.Close() |
| 170 url := r.Request.URL.String() |
170 if r.StatusCode != 200 || !end.MatchString(url) { | 171 if r.StatusCode != 200 || !end.MatchString(url) { |
171 t.Fatalf("Get got status %d at %q, want 200 matching /foo/$", r.
StatusCode, url) | 172 t.Fatalf("Get got status %d at %q, want 200 matching /foo/$", r.
StatusCode, url) |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 func TestMultipartRequest(t *testing.T) { | 176 func TestMultipartRequest(t *testing.T) { |
176 // Test that we can read the values and files of a· | 177 // Test that we can read the values and files of a· |
177 // multipart request with FormValue and FormFile, | 178 // multipart request with FormValue and FormFile, |
178 // and that ParseMultipartForm can be called multiple times. | 179 // and that ParseMultipartForm can be called multiple times. |
179 req := newTestMultipartRequest(t) | 180 req := newTestMultipartRequest(t) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 --MyBoundary | 306 --MyBoundary |
306 Content-Disposition: form-data; name="texta" | 307 Content-Disposition: form-data; name="texta" |
307 | 308 |
308 ` + textaValue + ` | 309 ` + textaValue + ` |
309 --MyBoundary | 310 --MyBoundary |
310 Content-Disposition: form-data; name="textb" | 311 Content-Disposition: form-data; name="textb" |
311 | 312 |
312 ` + textbValue + ` | 313 ` + textbValue + ` |
313 --MyBoundary-- | 314 --MyBoundary-- |
314 ` | 315 ` |
LEFT | RIGHT |