| OLD | NEW |
| 1 // Copyright (c) 2012, 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 library http_test; | 5 library http_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; |
| 11 import 'utils.dart'; | 11 import 'utils.dart'; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 'path': '/', | 157 'path': '/', |
| 158 'headers': { | 158 'headers': { |
| 159 'content-length': ['0'], | 159 'content-length': ['0'], |
| 160 'x-random-header': ['Value'], | 160 'x-random-header': ['Value'], |
| 161 'x-other-header': ['Other Value'] | 161 'x-other-header': ['Other Value'] |
| 162 }, | 162 }, |
| 163 })))); | 163 })))); |
| 164 }); | 164 }); |
| 165 | 165 |
| 166 test('read throws an error for a 4** status code', () { | 166 test('read throws an error for a 4** status code', () { |
| 167 http.read(serverUrl.resolve('/error')).catchError(expectAsync1((e) { | 167 http.read(serverUrl.resolve('/error')) |
| 168 expect(true, e.error is HttpException); | 168 .then((_) { throw "Error expected for readBytes"; }) |
| 169 })); | 169 .catchError(expectAsync1((e) { }), test: (e) => e is HttpException); |
| 170 }); | 170 }); |
| 171 | 171 |
| 172 test('readBytes', () { | 172 test('readBytes', () { |
| 173 var future = http.readBytes(serverUrl, headers: { | 173 var future = http.readBytes(serverUrl, headers: { |
| 174 'X-Random-Header': 'Value', | 174 'X-Random-Header': 'Value', |
| 175 'X-Other-Header': 'Other Value' | 175 'X-Other-Header': 'Other Value' |
| 176 }).then(expectAsync1((bytes) => new String.fromCharCodes(bytes))); | 176 }).then(expectAsync1((bytes) => new String.fromCharCodes(bytes))); |
| 177 | 177 |
| 178 expect(future, completion(parse(equals({ | 178 expect(future, completion(parse(equals({ |
| 179 'method': 'GET', | 179 'method': 'GET', |
| 180 'path': '/', | 180 'path': '/', |
| 181 'headers': { | 181 'headers': { |
| 182 'content-length': ['0'], | 182 'content-length': ['0'], |
| 183 'x-random-header': ['Value'], | 183 'x-random-header': ['Value'], |
| 184 'x-other-header': ['Other Value'] | 184 'x-other-header': ['Other Value'] |
| 185 }, | 185 }, |
| 186 })))); | 186 })))); |
| 187 }); | 187 }); |
| 188 | 188 |
| 189 test('readBytes throws an error for a 4** status code', () { | 189 test('readBytes throws an error for a 4** status code', () { |
| 190 http.readBytes(serverUrl.resolve('/error')).catchError(expectAsync1((e) { | 190 http.readBytes(serverUrl.resolve('/error')) |
| 191 expect(true, e.error is HttpException); | 191 .then((_) { throw "Error expected for readBytes"; }) |
| 192 })); | 192 .catchError(expectAsync1((e) { }), test: (e) => e is HttpException); |
| 193 }); | 193 }); |
| 194 }); | 194 }); |
| 195 } | 195 } |
| OLD | NEW |