| 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 library test_utils; | 5 library test_utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 response.headers.contentType = | 68 response.headers.contentType = |
| 69 new ContentType( | 69 new ContentType( |
| 70 "application", "json", charset: outputEncoding.name); | 70 "application", "json", charset: outputEncoding.name); |
| 71 response.headers.set('single', 'value'); | 71 response.headers.set('single', 'value'); |
| 72 | 72 |
| 73 var requestBody; | 73 var requestBody; |
| 74 if (requestBodyBytes.isEmpty) { | 74 if (requestBodyBytes.isEmpty) { |
| 75 requestBody = null; | 75 requestBody = null; |
| 76 } else if (request.headers.contentType.charset != null) { | 76 } else if (request.headers.contentType != null && |
| 77 request.headers.contentType.charset != null) { |
| 77 var encoding = requiredEncodingForCharset( | 78 var encoding = requiredEncodingForCharset( |
| 78 request.headers.contentType.charset); | 79 request.headers.contentType.charset); |
| 79 requestBody = encoding.decode(requestBodyBytes); | 80 requestBody = encoding.decode(requestBodyBytes); |
| 80 } else { | 81 } else { |
| 81 requestBody = requestBodyBytes; | 82 requestBody = requestBodyBytes; |
| 82 } | 83 } |
| 83 | 84 |
| 84 var content = { | 85 var content = { |
| 85 'method': request.method, | 86 'method': request.method, |
| 86 'path': request.uri.path, | 87 'path': request.uri.path, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const isSocketException = const _SocketException(); | 200 const isSocketException = const _SocketException(); |
| 200 | 201 |
| 201 /// A matcher for functions that throw SocketException. | 202 /// A matcher for functions that throw SocketException. |
| 202 const Matcher throwsSocketException = | 203 const Matcher throwsSocketException = |
| 203 const Throws(isSocketException); | 204 const Throws(isSocketException); |
| 204 | 205 |
| 205 class _SocketException extends TypeMatcher { | 206 class _SocketException extends TypeMatcher { |
| 206 const _SocketException() : super("SocketException"); | 207 const _SocketException() : super("SocketException"); |
| 207 bool matches(item, Map matchState) => item is SocketException; | 208 bool matches(item, Map matchState) => item is SocketException; |
| 208 } | 209 } |
| OLD | NEW |