| 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 part of vmservice_io; | 5 part of vmservice_io; |
| 6 | 6 |
| 7 class WebSocketClient extends Client { | 7 class WebSocketClient extends Client { |
| 8 static const int PARSE_ERROR_CODE = 4000; | 8 static const int PARSE_ERROR_CODE = 4000; |
| 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; | 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; |
| 10 static const int NOT_MAP_ERROR_CODE = 4002; | 10 static const int NOT_MAP_ERROR_CODE = 4002; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 final String path = | 129 final String path = |
| 130 request.uri.path == '/' ? ROOT_REDIRECT_PATH : request.uri.path; | 130 request.uri.path == '/' ? ROOT_REDIRECT_PATH : request.uri.path; |
| 131 | 131 |
| 132 if (path == WEBSOCKET_PATH) { | 132 if (path == WEBSOCKET_PATH) { |
| 133 WebSocketTransformer.upgrade(request).then((WebSocket webSocket) { | 133 WebSocketTransformer.upgrade(request).then((WebSocket webSocket) { |
| 134 new WebSocketClient(webSocket, _service); | 134 new WebSocketClient(webSocket, _service); |
| 135 }); | 135 }); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 var resource = Resource.resources[path]; | 139 Asset asset = assets[path]; |
| 140 if (resource != null) { | 140 if (asset != null) { |
| 141 // Serving up a static resource (e.g. .css, .html, .png). | 141 // Serving up a static asset (e.g. .css, .html, .png). |
| 142 request.response.headers.contentType = | 142 request.response.headers.contentType = |
| 143 ContentType.parse(resource.mimeType); | 143 ContentType.parse(asset.mimeType); |
| 144 request.response.add(resource.data); | 144 request.response.add(asset.data); |
| 145 request.response.close(); | 145 request.response.close(); |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 // HTTP based service request. | 148 // HTTP based service request. |
| 149 try { | 149 try { |
| 150 var client = new HttpRequestClient(request, _service); | 150 var client = new HttpRequestClient(request, _service); |
| 151 var message = new Message.fromUri(client, request.uri); | 151 var message = new Message.fromUri(client, request.uri); |
| 152 client.onMessage(null, message); | 152 client.onMessage(null, message); |
| 153 } catch (e) { | 153 } catch (e) { |
| 154 print('Unexpected error processing HTTP request uri: ' | 154 print('Unexpected error processing HTTP request uri: ' |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); | 214 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); |
| 215 _notifyServerState("", 0); | 215 _notifyServerState("", 0); |
| 216 return this; | 216 return this; |
| 217 }); | 217 }); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } | 220 } |
| 221 | 221 |
| 222 void _notifyServerState(String ip, int port) | 222 void _notifyServerState(String ip, int port) |
| 223 native "VMServiceIO_NotifyServerState"; | 223 native "VMServiceIO_NotifyServerState"; |
| OLD | NEW |