OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library request_test; | 5 library request_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 test('#maxRedirects', () { | 209 test('#maxRedirects', () { |
210 print("This test is known to be flaky, please ignore " | 210 print("This test is known to be flaky, please ignore " |
211 "(debug prints below added by sgjesse@)"); | 211 "(debug prints below added by sgjesse@)"); |
212 print("#maxRedirects test starting server..."); | 212 print("#maxRedirects test starting server..."); |
213 startServer(); | 213 startServer(); |
214 print("#maxRedirects test server running"); | 214 print("#maxRedirects test server running"); |
215 | 215 |
216 var request = new http.Request('POST', serverUrl.resolve('/loop?1')) | 216 var request = new http.Request('POST', serverUrl.resolve('/loop?1')) |
217 ..maxRedirects = 2; | 217 ..maxRedirects = 2; |
218 var future = request.send().catchError((AsyncError e) { | 218 var future = request.send().catchError((e) { |
219 print("#maxRedirects test exception received"); | 219 print("#maxRedirects test exception received"); |
220 expect(e.error, isRedirectLimitExceededException); | 220 expect(e.error, isRedirectLimitExceededException); |
221 expect(e.error.redirects.length, equals(2)); | 221 expect(e.error.redirects.length, equals(2)); |
222 }); | 222 }); |
223 future.catchError((_) {}).then(expectAsync1((_) { | 223 future.catchError((_) {}).then(expectAsync1((_) { |
224 print("#maxRedirects test stopping server..."); | 224 print("#maxRedirects test stopping server..."); |
225 stopServer(); | 225 stopServer(); |
226 print("#maxRedirects test server stopped"); | 226 print("#maxRedirects test server stopped"); |
227 })); | 227 })); |
228 | 228 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 }); | 389 }); |
390 | 390 |
391 group('#toString()', () { | 391 group('#toString()', () { |
392 test('includes the method and URL', () { | 392 test('includes the method and URL', () { |
393 var request = new http.Request('POST', dummyUrl); | 393 var request = new http.Request('POST', dummyUrl); |
394 expect(request.toString(), 'POST $dummyUrl'); | 394 expect(request.toString(), 'POST $dummyUrl'); |
395 }); | 395 }); |
396 }); | 396 }); |
397 } | 397 } |
398 | 398 |
OLD | NEW |