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 request.listen( | 200 response.headers.set( |
201 (_) {}, | 201 HttpHeaders.LOCATION, |
202 onDone: () { | 202 "http://127.0.0.1:${server.port}/303target"); |
203 response.headers.set( | 203 response.statusCode = HttpStatus.SEE_OTHER; |
204 HttpHeaders.LOCATION, | 204 response.close(); |
205 "http://127.0.0.1:${server.port}/303target"); | |
206 response.statusCode = HttpStatus.SEE_OTHER; | |
207 response.close(); | |
208 }); | |
209 }); | 205 }); |
210 }); | 206 }); |
211 addRequestHandler( | 207 addRequestHandler( |
212 "/303target", | 208 "/303target", |
213 (HttpRequest request, HttpResponse response) { | 209 (HttpRequest request, HttpResponse response) { |
214 Expect.equals("GET", request.method); | 210 Expect.equals("GET", request.method); |
215 response.close(); | 211 response.close(); |
216 }); | 212 }); |
217 | 213 |
218 // Setup redirect where we close the connection. | 214 // Setup redirect where we close the connection. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 testManualRedirectWithHeaders(); | 462 testManualRedirectWithHeaders(); |
467 testAutoRedirect(); | 463 testAutoRedirect(); |
468 testAutoRedirectWithHeaders(); | 464 testAutoRedirectWithHeaders(); |
469 testAutoRedirect301POST(); | 465 testAutoRedirect301POST(); |
470 testAutoRedirect303POST(); | 466 testAutoRedirect303POST(); |
471 testAutoRedirectLimit(); | 467 testAutoRedirectLimit(); |
472 testRedirectLoop(); | 468 testRedirectLoop(); |
473 testRedirectClosingConnection(); | 469 testRedirectClosingConnection(); |
474 testRedirectRelativeUrl(); | 470 testRedirectRelativeUrl(); |
475 } | 471 } |
OLD | NEW |