| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 get.handler; | 5 library get.handler; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/socket_server.dart'; | 10 import 'package:analysis_server/src/socket_server.dart'; |
| 11 import 'package:analyzer/file_system/file_system.dart'; | 11 import 'package:analyzer/file_system/file_system.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/java_engine.dart'; | 13 import 'package:analyzer/src/generated/java_engine.dart'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Instances of the class [GetHandler] handle GET requests. | 16 * Instances of the class [GetHandler] handle GET requests. |
| 17 */ | 17 */ |
| 18 class GetHandler { | 18 class GetHandler { |
| 19 /** | 19 /** |
| 20 * The path used to request the status of the analysis server as a whole. | 20 * The path used to request the status of the analysis server as a whole. |
| 21 */ | 21 */ |
| 22 static const String STATUS_PATH = '/status'; | 22 static const String STATUS_PATH = '/status'; |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * The socket server whose status is to be reported on. | 25 * The socket server whose status is to be reported on. |
| 26 */ | 26 */ |
| 27 SocketServer _server; | 27 SocketServer _server; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Buffer containing strings printed by the analysis server. |
| 31 */ |
| 32 List<String> _printBuffer; |
| 33 |
| 34 /** |
| 30 * Initialize a newly created handler for GET requests. | 35 * Initialize a newly created handler for GET requests. |
| 31 */ | 36 */ |
| 32 GetHandler(SocketServer this._server); | 37 GetHandler(this._server, this._printBuffer); |
| 33 | 38 |
| 34 /** | 39 /** |
| 35 * Handle a GET request received by the HTTP server. | 40 * Handle a GET request received by the HTTP server. |
| 36 */ | 41 */ |
| 37 void handleGetRequest(HttpRequest request) { | 42 void handleGetRequest(HttpRequest request) { |
| 38 String path = request.uri.path; | 43 String path = request.uri.path; |
| 39 if (path == STATUS_PATH) { | 44 if (path == STATUS_PATH) { |
| 40 _returnServerStatus(request); | 45 _returnServerStatus(request); |
| 41 } else { | 46 } else { |
| 42 _returnUnknownRequest(request); | 47 _returnUnknownRequest(request); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 response.write('</table>'); | 118 response.write('</table>'); |
| 114 List<CaughtException> exceptions = statistics.exceptions; | 119 List<CaughtException> exceptions = statistics.exceptions; |
| 115 if (!exceptions.isEmpty) { | 120 if (!exceptions.isEmpty) { |
| 116 response.write('<h2>Exceptions</h2>'); | 121 response.write('<h2>Exceptions</h2>'); |
| 117 exceptions.forEach((CaughtException exception) { | 122 exceptions.forEach((CaughtException exception) { |
| 118 response.write('<p>${exception.exception}</p>'); | 123 response.write('<p>${exception.exception}</p>'); |
| 119 }); | 124 }); |
| 120 } | 125 } |
| 121 }); | 126 }); |
| 122 } | 127 } |
| 128 response.write('<h1>Most recent strings printed by analysis server</h2>'); |
| 129 response.write('<pre>'); |
| 130 response.write(HTML_ESCAPE.convert(_printBuffer.join('\n'))); |
| 131 response.write('</pre>'); |
| 123 response.write('</body>'); | 132 response.write('</body>'); |
| 124 response.write('</html>'); | 133 response.write('</html>'); |
| 125 response.close(); | 134 response.close(); |
| 126 } | 135 } |
| 127 | 136 |
| 128 /** | 137 /** |
| 129 * Return an error in response to an unrecognized request received by the HTTP | 138 * Return an error in response to an unrecognized request received by the HTTP |
| 130 * server. | 139 * server. |
| 131 */ | 140 */ |
| 132 void _returnUnknownRequest(HttpRequest request) { | 141 void _returnUnknownRequest(HttpRequest request) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 response.write(value); | 162 response.write(value); |
| 154 if (header) { | 163 if (header) { |
| 155 response.write('</th>'); | 164 response.write('</th>'); |
| 156 } else { | 165 } else { |
| 157 response.write('</td>'); | 166 response.write('</td>'); |
| 158 } | 167 } |
| 159 }); | 168 }); |
| 160 response.write('</tr>'); | 169 response.write('</tr>'); |
| 161 } | 170 } |
| 162 } | 171 } |
| OLD | NEW |