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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:analysis_server/src/channel/web_socket_channel.dart'; | 8 import 'package:analysis_server/src/channel/web_socket_channel.dart'; |
9 import 'package:analysis_server/src/socket_server.dart'; | 9 import 'package:analysis_server/src/socket_server.dart'; |
| 10 import 'package:analysis_server/src/status/diagnostics.dart'; |
10 import 'package:analysis_server/src/status/get_handler.dart'; | 11 import 'package:analysis_server/src/status/get_handler.dart'; |
11 import 'package:analysis_server/src/status/get_handler2.dart'; | |
12 | 12 |
13 /** | 13 /** |
14 * Instances of the class [HttpServer] implement a simple HTTP server. The | 14 * Instances of the class [HttpServer] implement a simple HTTP server. The |
15 * server: | 15 * server: |
16 * | 16 * |
17 * - listens for an UPGRADE request in order to start an analysis server | 17 * - listens for an UPGRADE request in order to start an analysis server |
18 * - serves diagnostic information as html pages | 18 * - serves diagnostic information as html pages |
19 */ | 19 */ |
20 class HttpAnalysisServer { | 20 class HttpAnalysisServer { |
21 /** | 21 /** |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return null; | 89 return null; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 /** | 93 /** |
94 * Handle a GET request received by the HTTP server. | 94 * Handle a GET request received by the HTTP server. |
95 */ | 95 */ |
96 void _handleGetRequest(HttpRequest request) { | 96 void _handleGetRequest(HttpRequest request) { |
97 if (getHandler == null) { | 97 if (getHandler == null) { |
98 if (socketServer.analysisServer.options.enableNewAnalysisDriver) { | 98 if (socketServer.analysisServer.options.enableNewAnalysisDriver) { |
99 getHandler = new GetHandler2(socketServer, _printBuffer); | 99 // TODO(devoncarew): Remove GetHandler2. |
| 100 getHandler = new DiagnosticsSite(socketServer, _printBuffer); |
100 } else { | 101 } else { |
| 102 // TODO(devoncarew): GetHandler is essentially dead code. |
101 getHandler = new GetHandler(socketServer, _printBuffer); | 103 getHandler = new GetHandler(socketServer, _printBuffer); |
102 } | 104 } |
103 } | 105 } |
104 getHandler.handleGetRequest(request); | 106 getHandler.handleGetRequest(request); |
105 } | 107 } |
106 | 108 |
107 /** | 109 /** |
108 * Attach a listener to a newly created HTTP server. | 110 * Attach a listener to a newly created HTTP server. |
109 */ | 111 */ |
110 void _handleServer(HttpServer httpServer) { | 112 void _handleServer(HttpServer httpServer) { |
(...skipping 28 matching lines...) Expand all Loading... |
139 */ | 141 */ |
140 void _returnUnknownRequest(HttpRequest request) { | 142 void _returnUnknownRequest(HttpRequest request) { |
141 HttpResponse response = request.response; | 143 HttpResponse response = request.response; |
142 response.statusCode = HttpStatus.NOT_FOUND; | 144 response.statusCode = HttpStatus.NOT_FOUND; |
143 response.headers.contentType = | 145 response.headers.contentType = |
144 new ContentType("text", "plain", charset: "utf-8"); | 146 new ContentType("text", "plain", charset: "utf-8"); |
145 response.write('Not found'); | 147 response.write('Not found'); |
146 response.close(); | 148 response.close(); |
147 } | 149 } |
148 } | 150 } |
| 151 |
| 152 /** |
| 153 * Instances of the class [AbstractGetHandler] handle GET requests. |
| 154 */ |
| 155 abstract class AbstractGetHandler { |
| 156 /** |
| 157 * Handle a GET request received by the HTTP server. |
| 158 */ |
| 159 void handleGetRequest(HttpRequest request); |
| 160 } |
OLD | NEW |