| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * HTTP status codes. | 6 * HTTP status codes. |
| 7 */ | 7 */ |
| 8 interface HttpStatus { | 8 interface HttpStatus { |
| 9 static final int CONTINUE = 100; | 9 static final int CONTINUE = 100; |
| 10 static final int SWITCHING_PROTOCOLS = 101; | 10 static final int SWITCHING_PROTOCOLS = 101; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * HTTP server. | 56 * HTTP server. |
| 57 */ | 57 */ |
| 58 interface HttpServer default _HttpServer { | 58 interface HttpServer default _HttpServer { |
| 59 HttpServer(); | 59 HttpServer(); |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Start listening for HTTP requests on the specified [host] and | 62 * Start listening for HTTP requests on the specified [host] and |
| 63 * [port]. For each HTTP request the handler set through [onRequest] | 63 * [port]. If a [port] of 0 is specified the server will choose an |
| 64 * will be invoked. If a [port] of 0 is specified the server will | 64 * ephemeral port. The optional argument [backlog] can be used to |
| 65 * choose an ephemeral port. The optional argument [backlog] can be | 65 * specify the listen backlog for the underlying OS listen |
| 66 * used to specify the listen backlog for the underlying OS listen | 66 * setup. See [addRequestHandler] and [defaultRequestHandler] for |
| 67 * setup. | 67 * information on how incoming HTTP requests are handled. |
| 68 */ | 68 */ |
| 69 void listen(String host, int port, [int backlog]); | 69 void listen(String host, int port, [int backlog]); |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Attach the HTTP server to an existing ServerSocket. If the HttpServer is | 72 * Attach the HTTP server to an existing [:ServerSocket:]. If the |
| 73 * closed, the HttpServer will just detach itself, and not close | 73 * [HttpServer] is closed, the [HttpServer] will just detach itself, |
| 74 * [serverSocket]. | 74 * and not close [serverSocket]. |
| 75 */ | 75 */ |
| 76 void listenOn(ServerSocket serverSocket); | 76 void listenOn(ServerSocket serverSocket); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Adds a request handler to the list of request handlers. The | 79 * Adds a request handler to the list of request handlers. The |
| 80 * function [matcher] is called with the request and must return | 80 * function [matcher] is called with the request and must return |
| 81 * [:true:] if the [handler] should handle the request. The first | 81 * [:true:] if the [handler] should handle the request. The first |
| 82 * handler for which [matcher] returns [:true:] will be handed the | 82 * handler for which [matcher] returns [:true:] will be handed the |
| 83 * request. | 83 * request. |
| 84 */ | 84 */ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 /** | 264 /** |
| 265 * Remove all values for the specified header name. Some headers | 265 * Remove all values for the specified header name. Some headers |
| 266 * have system supplied values and for these the system supplied | 266 * have system supplied values and for these the system supplied |
| 267 * values will still be added to the collection of values for the | 267 * values will still be added to the collection of values for the |
| 268 * header. | 268 * header. |
| 269 */ | 269 */ |
| 270 void removeAll(String name); | 270 void removeAll(String name); |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * Enumerate the headers applying the function [f] to each | 273 * Enumerate the headers applying the function [f] to each |
| 274 * header. The header names passed in [name] will be all lower | 274 * header. The header name passed in [name] will be all lower |
| 275 * case. | 275 * case. |
| 276 */ | 276 */ |
| 277 void forEach(void f(String name, List<String> values)); | 277 void forEach(void f(String name, List<String> values)); |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * Gets and sets the date. The value of this property will | 280 * Gets and sets the date. The value of this property will |
| 281 * reflect the "Date" header | 281 * reflect the "Date" header |
| 282 */ | 282 */ |
| 283 Date date; | 283 Date date; |
| 284 | 284 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 Socket get socket(); | 590 Socket get socket(); |
| 591 List<int> get unparsedData(); | 591 List<int> get unparsedData(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 | 594 |
| 595 class HttpException implements Exception { | 595 class HttpException implements Exception { |
| 596 const HttpException([String this.message = ""]); | 596 const HttpException([String this.message = ""]); |
| 597 String toString() => "HttpException: $message"; | 597 String toString() => "HttpException: $message"; |
| 598 final String message; | 598 final String message; |
| 599 } | 599 } |
| OLD | NEW |