| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 response.statusCode = 302; | 48 response.statusCode = 302; |
| 49 response.headers.set('location', serverUrl.resolve('/').toString()); | 49 response.headers.set('location', serverUrl.resolve('/').toString()); |
| 50 response.contentLength = 0; | 50 response.contentLength = 0; |
| 51 response.outputStream.close(); | 51 response.outputStream.close(); |
| 52 }); | 52 }); |
| 53 | 53 |
| 54 _server.defaultRequestHandler = (request, response) { | 54 _server.defaultRequestHandler = (request, response) { |
| 55 consumeInputStream(request.inputStream).then((requestBodyBytes) { | 55 consumeInputStream(request.inputStream).then((requestBodyBytes) { |
| 56 response.statusCode = 200; | 56 response.statusCode = 200; |
| 57 response.headers.contentType = new ContentType("application", "json"); | 57 response.headers.contentType = new ContentType("application", "json"); |
| 58 response.headers.set('single', 'value'); |
| 58 | 59 |
| 59 var requestBody; | 60 var requestBody; |
| 60 if (requestBodyBytes.isEmpty) { | 61 if (requestBodyBytes.isEmpty) { |
| 61 requestBody = null; | 62 requestBody = null; |
| 62 } else if (request.headers.contentType.charset != null) { | 63 } else if (request.headers.contentType.charset != null) { |
| 63 var encoding = requiredEncodingForCharset( | 64 var encoding = requiredEncodingForCharset( |
| 64 request.headers.contentType.charset); | 65 request.headers.contentType.charset); |
| 65 requestBody = decodeString(requestBodyBytes, encoding); | 66 requestBody = decodeString(requestBodyBytes, encoding); |
| 66 } else { | 67 } else { |
| 67 requestBody = requestBodyBytes; | 68 requestBody = requestBodyBytes; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const isSocketIOException = const _SocketIOException(); | 184 const isSocketIOException = const _SocketIOException(); |
| 184 | 185 |
| 185 /// A matcher for functions that throw SocketIOException. | 186 /// A matcher for functions that throw SocketIOException. |
| 186 const Matcher throwsSocketIOException = | 187 const Matcher throwsSocketIOException = |
| 187 const Throws(isSocketIOException); | 188 const Throws(isSocketIOException); |
| 188 | 189 |
| 189 class _SocketIOException extends TypeMatcher { | 190 class _SocketIOException extends TypeMatcher { |
| 190 const _SocketIOException() : super("SocketIOException"); | 191 const _SocketIOException() : super("SocketIOException"); |
| 191 bool matches(item, MatchState matchState) => item is SocketIOException; | 192 bool matches(item, MatchState matchState) => item is SocketIOException; |
| 192 } | 193 } |
| OLD | NEW |