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 dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * HTTP status codes. | 8 * HTTP status codes. |
9 */ | 9 */ |
10 abstract class HttpStatus { | 10 abstract class HttpStatus { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 static const int BAD_GATEWAY = 502; | 48 static const int BAD_GATEWAY = 502; |
49 static const int SERVICE_UNAVAILABLE = 503; | 49 static const int SERVICE_UNAVAILABLE = 503; |
50 static const int GATEWAY_TIMEOUT = 504; | 50 static const int GATEWAY_TIMEOUT = 504; |
51 static const int HTTP_VERSION_NOT_SUPPORTED = 505; | 51 static const int HTTP_VERSION_NOT_SUPPORTED = 505; |
52 // Client generated status code. | 52 // Client generated status code. |
53 static const int NETWORK_CONNECT_TIMEOUT_ERROR = 599; | 53 static const int NETWORK_CONNECT_TIMEOUT_ERROR = 599; |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 /** | 57 /** |
58 * HTTP server. | 58 * The [HttpServer] class implements the server side of the HTTP |
| 59 * protocol. The [HttpServer] is a [Stream] of [HttpRequest]s. Each |
| 60 * [HttpRequest] has an associated [HttpResponse] object as its |
| 61 * [HttpRequest.response] member, and the server responds to a request by |
| 62 * writing to that [HttpResponse] object. |
| 63 * |
| 64 * Incomplete requests where all or parts of the header is missing, are |
| 65 * ignored and no exceptions or [HttpRequest] objects are generated for them. |
| 66 * Likewise, when writing to a [HttpResponse], any [Socket] exceptions are |
| 67 * ignored and any future writes are ignored. |
| 68 * |
| 69 * The [HttpRequest] exposes the request headers, and provides the request body, |
| 70 * if it exists, as a stream of data. If the body is unread, it'll be drained |
| 71 * when the [HttpResponse] is being written to or closed. |
| 72 * |
| 73 * The following example shows how to bind a [HttpServer] to a IPv6 |
| 74 * [InternetAddress] on port 80, and listening to requests. |
| 75 * |
| 76 * HttpServer.bind(InternetAddress.ANY_IP_V6, 80).then((server) { |
| 77 * server.listen((HttpRequest request) { |
| 78 * // Handle requests. |
| 79 * }); |
| 80 * }); |
59 */ | 81 */ |
60 abstract class HttpServer implements Stream<HttpRequest> { | 82 abstract class HttpServer implements Stream<HttpRequest> { |
61 // TODO(ajohnsen): Document with example, once the stream API is final. | |
62 // TODO(ajohnsen): Add HttpServer.secure. | |
63 /** | 83 /** |
64 * Starts listening for HTTP requests on the specified [address] and | 84 * Starts listening for HTTP requests on the specified [address] and |
65 * [port]. | 85 * [port]. |
66 * | 86 * |
67 * The [address] can either be a [String] or an | 87 * The [address] can either be a [String] or an |
68 * [InternetAddress]. If [address] is a [String], [bind] will | 88 * [InternetAddress]. If [address] is a [String], [bind] will |
69 * perform a [InternetAddress.lookup] and use the first value in the | 89 * perform a [InternetAddress.lookup] and use the first value in the |
70 * list. To listen on the loopback adapter, which will allow only | 90 * list. To listen on the loopback adapter, which will allow only |
71 * incoming connections from the local host, use the value | 91 * incoming connections from the local host, use the value |
72 * [InternetAddress.LOOPBACK_IP_V4] or | 92 * [InternetAddress.LOOPBACK_IP_V4] or |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 | 1408 |
1389 class RedirectException implements HttpException { | 1409 class RedirectException implements HttpException { |
1390 final String message; | 1410 final String message; |
1391 final List<RedirectInfo> redirects; | 1411 final List<RedirectInfo> redirects; |
1392 | 1412 |
1393 const RedirectException(String this.message, | 1413 const RedirectException(String this.message, |
1394 List<RedirectInfo> this.redirects); | 1414 List<RedirectInfo> this.redirects); |
1395 | 1415 |
1396 String toString() => "RedirectException: $message"; | 1416 String toString() => "RedirectException: $message"; |
1397 } | 1417 } |
OLD | NEW |