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 test_utils; | 5 library test_utils; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 var encoding = requiredEncodingForCharset( | 63 var encoding = requiredEncodingForCharset( |
64 request.headers.contentType.charset); | 64 request.headers.contentType.charset); |
65 requestBody = decodeString(requestBodyBytes, encoding); | 65 requestBody = decodeString(requestBodyBytes, encoding); |
66 } else { | 66 } else { |
67 requestBody = requestBodyBytes; | 67 requestBody = requestBodyBytes; |
68 } | 68 } |
69 | 69 |
70 var content = { | 70 var content = { |
71 'method': request.method, | 71 'method': request.method, |
72 'path': request.path, | 72 'path': request.path, |
73 'headers': <String>{} | 73 'headers': {} |
74 }; | 74 }; |
75 if (requestBody != null) content['body'] = requestBody; | 75 if (requestBody != null) content['body'] = requestBody; |
76 request.headers.forEach((name, values) { | 76 request.headers.forEach((name, values) { |
77 // These headers are automatically generated by dart:io, so we don't | 77 // These headers are automatically generated by dart:io, so we don't |
78 // want to test them here. | 78 // want to test them here. |
79 if (name == 'cookie' || name == 'host') return; | 79 if (name == 'cookie' || name == 'host') return; |
80 | 80 |
81 content['headers'][name] = values; | 81 content['headers'][name] = values; |
82 }); | 82 }); |
83 | 83 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 const isSocketIOException = const _SocketIOException(); | 183 const isSocketIOException = const _SocketIOException(); |
184 | 184 |
185 /// A matcher for functions that throw SocketIOException. | 185 /// A matcher for functions that throw SocketIOException. |
186 const Matcher throwsSocketIOException = | 186 const Matcher throwsSocketIOException = |
187 const Throws(isSocketIOException); | 187 const Throws(isSocketIOException); |
188 | 188 |
189 class _SocketIOException extends TypeMatcher { | 189 class _SocketIOException extends TypeMatcher { |
190 const _SocketIOException() : super("SocketIOException"); | 190 const _SocketIOException() : super("SocketIOException"); |
191 bool matches(item, MatchState matchState) => item is SocketIOException; | 191 bool matches(item, MatchState matchState) => item is SocketIOException; |
192 } | 192 } |
OLD | NEW |