OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 import "dart:uri"; | 9 import "dart:uri"; |
10 | 10 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 Expect.fail("Redirect of POST should not happen"); | 190 Expect.fail("Redirect of POST should not happen"); |
191 } | 191 } |
192 ); | 192 ); |
193 | 193 |
194 // Setup redirect for 303 where POST should turn into GET. | 194 // Setup redirect for 303 where POST should turn into GET. |
195 addRequestHandler( | 195 addRequestHandler( |
196 "/303src", | 196 "/303src", |
197 (HttpRequest request, HttpResponse response) { | 197 (HttpRequest request, HttpResponse response) { |
198 request.listen((_) {}, onDone: () { | 198 request.listen((_) {}, onDone: () { |
199 Expect.equals("POST", request.method); | 199 Expect.equals("POST", request.method); |
200 response.headers.set( | 200 request.listen( |
201 HttpHeaders.LOCATION, | 201 (_) {}, |
202 "http://127.0.0.1:${server.port}/303target"); | 202 onDone: () { |
203 response.statusCode = HttpStatus.SEE_OTHER; | 203 response.headers.set( |
204 response.close(); | 204 HttpHeaders.LOCATION, |
| 205 "http://127.0.0.1:${server.port}/303target"); |
| 206 response.statusCode = HttpStatus.SEE_OTHER; |
| 207 response.close(); |
| 208 }); |
205 }); | 209 }); |
206 }); | 210 }); |
207 addRequestHandler( | 211 addRequestHandler( |
208 "/303target", | 212 "/303target", |
209 (HttpRequest request, HttpResponse response) { | 213 (HttpRequest request, HttpResponse response) { |
210 Expect.equals("GET", request.method); | 214 Expect.equals("GET", request.method); |
211 response.close(); | 215 response.close(); |
212 }); | 216 }); |
213 | 217 |
214 // Setup redirect where we close the connection. | 218 // Setup redirect where we close the connection. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 testManualRedirectWithHeaders(); | 466 testManualRedirectWithHeaders(); |
463 testAutoRedirect(); | 467 testAutoRedirect(); |
464 testAutoRedirectWithHeaders(); | 468 testAutoRedirectWithHeaders(); |
465 testAutoRedirect301POST(); | 469 testAutoRedirect301POST(); |
466 testAutoRedirect303POST(); | 470 testAutoRedirect303POST(); |
467 testAutoRedirectLimit(); | 471 testAutoRedirectLimit(); |
468 testRedirectLoop(); | 472 testRedirectLoop(); |
469 testRedirectClosingConnection(); | 473 testRedirectClosingConnection(); |
470 testRedirectRelativeUrl(); | 474 testRedirectRelativeUrl(); |
471 } | 475 } |
OLD | NEW |