| Index: tools/testing/dart/http_server.dart
|
| diff --git a/tools/testing/dart/http_server.dart b/tools/testing/dart/http_server.dart
|
| index 08c26f6caf21de28d732d3810a75339efeb45b13..feffa4c5d988fe58168a55169027aa049046aa99 100644
|
| --- a/tools/testing/dart/http_server.dart
|
| +++ b/tools/testing/dart/http_server.dart
|
| @@ -26,6 +26,8 @@ import 'utils.dart';
|
| /// directory (i.e. '$BuildDirectory/X').
|
| /// /FOO/packages/BAR: This will serve the corresponding file from the packages
|
| /// directory (i.e. '$BuildDirectory/packages/BAR')
|
| +/// /ws: This will upgrade the connection to a WebSocket connection and echo
|
| +/// all data back to the client.
|
| ///
|
| /// In case a path does not refer to a file but rather to a directory, a
|
| /// directory listing will be displayed.
|
| @@ -132,6 +134,8 @@ class TestingServers {
|
| httpServer.listen((HttpRequest request) {
|
| if (request.uri.path == "/echo") {
|
| _handleEchoRequest(request, request.response);
|
| + } else if (request.uri.path == '/ws') {
|
| + _handleWebSocketRequest(request);
|
| } else {
|
| _handleFileOrDirectoryRequest(
|
| request, request.response, allowedPort);
|
| @@ -186,6 +190,21 @@ class TestingServers {
|
| });
|
| }
|
|
|
| + void _handleWebSocketRequest(HttpRequest request) {
|
| + WebSocketTransformer.upgrade(request).then((websocket) {
|
| + websocket.listen((data) {
|
| + websocket.send(data);
|
| + websocket.close();
|
| + }, onError: (e) {
|
| + DebugLogger.warning(
|
| + 'HttpServer: error while echoing to WebSocket: $e');
|
| + });
|
| + }).catchError((e) {
|
| + DebugLogger.warning(
|
| + 'HttpServer: error while transforming to WebSocket: $e');
|
| + });
|
| + }
|
| +
|
| Path _getFilePathFromRequestPath(String urlRequestPath) {
|
| // Go to the top of the file to see an explanation of the URL path scheme.
|
| var requestPath = new Path(urlRequestPath.substring(1)).canonicalize();
|
|
|