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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 /** | 57 /** |
58 * HTTP server. | 58 * HTTP server. |
59 */ | 59 */ |
60 abstract class HttpServer implements Stream<HttpRequest> { | 60 abstract class HttpServer implements Stream<HttpRequest> { |
61 // TODO(ajohnsen): Document with example, once the stream API is final. | 61 // TODO(ajohnsen): Document with example, once the stream API is final. |
62 // TODO(ajohnsen): Add HttpServer.secure. | 62 // TODO(ajohnsen): Add HttpServer.secure. |
63 /** | 63 /** |
64 * Starts listening for HTTP requests on the specified [address] and | 64 * Starts listening for HTTP requests on the specified [address] and |
65 * [port]. | 65 * [port]. |
66 * | 66 * |
67 * The default value for [address] is 127.0.0.1, which will allow | 67 * The [address] can either be a [String] or an |
68 * only incoming connections from the local host. To allow for | 68 * [InternetAddress]. If [address] is a [String], [bind] will |
69 * incoming connection from the network use either the value 0.0.0.0 | 69 * perform a [InternetAddress.lookup] and use the first value in the |
70 * to bind to all interfaces or the IP address of a specific | 70 * list. To listen on the loopback adapter, which will allow only |
71 * interface. | 71 * incoming connections from the local host, use the value |
| 72 * [InternetAddress.LOOPBACK_IP_V4] or |
| 73 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming |
| 74 * connection from the network use either one of the values |
| 75 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to |
| 76 * bind to all interfaces or the IP address of a specific interface. |
72 * | 77 * |
73 * If [port] has the value [:0:] (the default) an ephemeral port | 78 * If [port] has the value [:0:] an ephemeral port will be chosen by |
74 * will be chosen by the system. The actual port used can be | 79 * the system. The actual port used can be retrieved using the |
75 * retrieved using the [:port:] getter. | 80 * [port] getter. |
76 * | 81 * |
77 * The optional argument [backlog] can be used to specify the listen | 82 * The optional argument [backlog] can be used to specify the listen |
78 * backlog for the underlying OS listen setup. If [backlog] has the | 83 * backlog for the underlying OS listen setup. If [backlog] has the |
79 * value of [:0:] (the default) a reasonable value will be chosen by | 84 * value of [:0:] (the default) a reasonable value will be chosen by |
80 * the system. | 85 * the system. |
81 */ | 86 */ |
82 static Future<HttpServer> bind([String address = "127.0.0.1", | 87 static Future<HttpServer> bind(address, |
83 int port = 0, | 88 int port, |
84 int backlog = 0]) | 89 {int backlog: 0}) |
85 => _HttpServer.bind(address, port, backlog); | 90 => _HttpServer.bind(address, port, backlog); |
86 | 91 |
87 /** | 92 /** |
88 * Starts listening for HTTPS requests on the specified [address] and | 93 * The [address] can either be a [String] or an |
89 * [port]. If a [port] of 0 is specified the server will choose an | 94 * [InternetAddress]. If [address] is a [String], [bind] will |
90 * ephemeral port. The optional argument [backlog] can be used to | 95 * perform a [InternetAddress.lookup] and use the first value in the |
91 * specify the listen backlog for the underlying OS listen | 96 * list. To listen on the loopback adapter, which will allow only |
92 * setup. | 97 * incoming connections from the local host, use the value |
| 98 * [InternetAddress.LOOPBACK_IP_V4] or |
| 99 * [InternetAddress.LOOPBACK_IP_V6]. To allow for incoming |
| 100 * connection from the network use either one of the values |
| 101 * [InternetAddress.ANY_IP_V4] or [InternetAddress.ANY_IP_V6] to |
| 102 * bind to all interfaces or the IP address of a specific interface. |
| 103 * |
| 104 * If [port] has the value [:0:] an ephemeral port will be chosen by |
| 105 * the system. The actual port used can be retrieved using the |
| 106 * [port] getter. |
| 107 * |
| 108 * The optional argument [backlog] can be used to specify the listen |
| 109 * backlog for the underlying OS listen setup. If [backlog] has the |
| 110 * value of [:0:] (the default) a reasonable value will be chosen by |
| 111 * the system. |
93 * | 112 * |
94 * The certificate with Distinguished Name [certificateName] is looked | 113 * The certificate with Distinguished Name [certificateName] is looked |
95 * up in the certificate database, and is used as the server certificate. | 114 * up in the certificate database, and is used as the server certificate. |
96 * if [requestClientCertificate] is true, the server will request clients | 115 * if [requestClientCertificate] is true, the server will request clients |
97 * to authenticate with a client certificate. | 116 * to authenticate with a client certificate. |
98 */ | 117 */ |
99 | 118 |
100 static Future<HttpServer> bindSecure(String address, | 119 static Future<HttpServer> bindSecure(address, |
101 int port, | 120 int port, |
102 {int backlog: 0, | 121 {int backlog: 0, |
103 String certificateName, | 122 String certificateName, |
104 bool requestClientCertificate: false}) | 123 bool requestClientCertificate: false}) |
105 => _HttpServer.bindSecure(address, | 124 => _HttpServer.bindSecure(address, |
106 port, | 125 port, |
107 backlog, | 126 backlog, |
108 certificateName, | 127 certificateName, |
109 requestClientCertificate); | 128 requestClientCertificate); |
110 | 129 |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 class RedirectLimitExceededException extends RedirectException { | 1339 class RedirectLimitExceededException extends RedirectException { |
1321 const RedirectLimitExceededException(List<RedirectInfo> redirects) | 1340 const RedirectLimitExceededException(List<RedirectInfo> redirects) |
1322 : super("Redirect limit exceeded", redirects); | 1341 : super("Redirect limit exceeded", redirects); |
1323 } | 1342 } |
1324 | 1343 |
1325 | 1344 |
1326 class RedirectLoopException extends RedirectException { | 1345 class RedirectLoopException extends RedirectException { |
1327 const RedirectLoopException(List<RedirectInfo> redirects) | 1346 const RedirectLoopException(List<RedirectInfo> redirects) |
1328 : super("Redirect loop detected", redirects); | 1347 : super("Redirect loop detected", redirects); |
1329 } | 1348 } |
OLD | NEW |