Chromium Code Reviews| 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, where the | |
| 60 * [HttpRequest] class have a [HttpResponse] associated, through the response | |
|
Bill Hesse
2013/06/27 10:21:03
Instead of ", where the ...", how about "Each [Htt
Anders Johnsen
2013/06/27 10:28:35
Done.
| |
| 61 * field. | |
| 62 * | |
| 63 * Incomplete requests where all or parts of the header is missing, are | |
| 64 * ignored and no exceptions are generated for them. Likewise, when writing to a | |
|
Bill Hesse
2013/06/27 10:21:03
no exceptions or HttpRequest objects are generated
Anders Johnsen
2013/06/27 10:28:35
Done.
| |
| 65 * [HttpResponse], any Socket exceptions are ignore and any future data is | |
|
Bill Hesse
2013/06/27 10:21:03
[Socket] exceptions? ignored
What does "any f
Anders Johnsen
2013/06/27 10:28:35
Done.
| |
| 66 * ignored. | |
| 67 * | |
| 68 * The [HttpRequest] implements a [Stream] and provided the body as such. If the | |
|
Bill Hesse
2013/06/27 10:21:03
The [HttpRequest] exposes the request headers, and
Anders Johnsen
2013/06/27 10:28:35
Done.
| |
| 69 * body is unread, it'll be drained when the [HttpResponse] is being written | |
| 70 * to or closed. | |
| 71 * | |
| 72 * The following example shows how to bind a [HttpServer] to a IPv6 | |
| 73 * [InternetAddress] on port 80, and listening to requests. | |
| 74 * | |
| 75 * HttpServer.bind(InternetAddress.ANY_IP_V6, 80).then((server) { | |
| 76 * server.listen((HttpRequest request) { | |
| 77 * // Handle requests. | |
|
Bill Hesse
2013/06/27 10:21:03
Would it be misleading to just show
request.respon
Anders Johnsen
2013/06/27 10:28:35
I think so. I want the example to just show how to
| |
| 78 * }); | |
| 79 * }); | |
| 59 */ | 80 */ |
| 60 abstract class HttpServer implements Stream<HttpRequest> { | 81 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 /** | 82 /** |
| 64 * Starts listening for HTTP requests on the specified [address] and | 83 * Starts listening for HTTP requests on the specified [address] and |
| 65 * [port]. | 84 * [port]. |
| 66 * | 85 * |
| 67 * The [address] can either be a [String] or an | 86 * The [address] can either be a [String] or an |
| 68 * [InternetAddress]. If [address] is a [String], [bind] will | 87 * [InternetAddress]. If [address] is a [String], [bind] will |
| 69 * perform a [InternetAddress.lookup] and use the first value in the | 88 * perform a [InternetAddress.lookup] and use the first value in the |
| 70 * list. To listen on the loopback adapter, which will allow only | 89 * list. To listen on the loopback adapter, which will allow only |
| 71 * incoming connections from the local host, use the value | 90 * incoming connections from the local host, use the value |
| 72 * [InternetAddress.LOOPBACK_IP_V4] or | 91 * [InternetAddress.LOOPBACK_IP_V4] or |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 | 1407 |
| 1389 class RedirectException implements HttpException { | 1408 class RedirectException implements HttpException { |
| 1390 final String message; | 1409 final String message; |
| 1391 final List<RedirectInfo> redirects; | 1410 final List<RedirectInfo> redirects; |
| 1392 | 1411 |
| 1393 const RedirectException(String this.message, | 1412 const RedirectException(String this.message, |
| 1394 List<RedirectInfo> this.redirects); | 1413 List<RedirectInfo> this.redirects); |
| 1395 | 1414 |
| 1396 String toString() => "RedirectException: $message"; | 1415 String toString() => "RedirectException: $message"; |
| 1397 } | 1416 } |
| OLD | NEW |