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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 var resource = Resource.resources[path]; | 139 var resource = Resource.resources[path]; |
140 if (resource != null) { | 140 if (resource != null) { |
141 // Serving up a static resource (e.g. .css, .html, .png). | 141 // Serving up a static resource (e.g. .css, .html, .png). |
142 request.response.headers.contentType = | 142 request.response.headers.contentType = |
143 ContentType.parse(resource.mimeType); | 143 ContentType.parse(resource.mimeType); |
144 request.response.add(resource.data); | 144 request.response.add(resource.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 var client = new HttpRequestClient(request, _service); | 149 try { |
150 var message = new Message.fromUri(client, request.uri); | 150 var client = new HttpRequestClient(request, _service); |
151 client.onMessage(null, message); | 151 var message = new Message.fromUri(client, request.uri); |
| 152 client.onMessage(null, message); |
| 153 } catch (e) { |
| 154 print('Unexpected error processing HTTP request uri: ' |
| 155 '${request.uri}\n$e\n'); |
| 156 rethrow; |
| 157 } |
| 158 |
152 } | 159 } |
153 | 160 |
154 Future startup() { | 161 Future startup() { |
155 if (_server != null) { | 162 if (_server != null) { |
156 // Already running. | 163 // Already running. |
157 return new Future.value(this); | 164 return new Future.value(this); |
158 } | 165 } |
159 | 166 |
160 // Startup HTTP server. | 167 // Startup HTTP server. |
161 return HttpServer.bind(_ip, _port).then((s) { | 168 return HttpServer.bind(_ip, _port).then((s) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 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'); |
208 _notifyServerState("", 0); | 215 _notifyServerState("", 0); |
209 return this; | 216 return this; |
210 }); | 217 }); |
211 } | 218 } |
212 | 219 |
213 } | 220 } |
214 | 221 |
215 void _notifyServerState(String ip, int port) | 222 void _notifyServerState(String ip, int port) |
216 native "VMServiceIO_NotifyServerState"; | 223 native "VMServiceIO_NotifyServerState"; |
OLD | NEW |