| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 * [port] getter. | 268 * [port] getter. |
| 269 * | 269 * |
| 270 * The optional argument [backlog] can be used to specify the listen | 270 * The optional argument [backlog] can be used to specify the listen |
| 271 * backlog for the underlying OS listen setup. If [backlog] has the | 271 * backlog for the underlying OS listen setup. If [backlog] has the |
| 272 * value of [:0:] (the default) a reasonable value will be chosen by | 272 * value of [:0:] (the default) a reasonable value will be chosen by |
| 273 * the system. | 273 * the system. |
| 274 * | 274 * |
| 275 * If [requestClientCertificate] is true, the server will | 275 * If [requestClientCertificate] is true, the server will |
| 276 * request clients to authenticate with a client certificate. | 276 * request clients to authenticate with a client certificate. |
| 277 * The server will advertise the names of trusted issuers of client | 277 * The server will advertise the names of trusted issuers of client |
| 278 * certificates, getting them from [context], where they have been | 278 * certificates, getting them from a [SecurityContext], where they have been |
| 279 * set using [SecurityContext.setClientAuthorities]. | 279 * set using [SecurityContext.setClientAuthorities]. |
| 280 * | 280 * |
| 281 * The optional argument [shared] specifies whether additional HttpServer | 281 * The optional argument [shared] specifies whether additional HttpServer |
| 282 * objects can bind to the same combination of `address`, `port` and `v6Only`. | 282 * objects can bind to the same combination of `address`, `port` and `v6Only`. |
| 283 * If `shared` is `true` and more `HttpServer`s from this isolate or other | 283 * If `shared` is `true` and more `HttpServer`s from this isolate or other |
| 284 * isolates are bound to the port, then the incoming connections will be | 284 * isolates are bound to the port, then the incoming connections will be |
| 285 * distributed among all the bound `HttpServer`s. Connections can be | 285 * distributed among all the bound `HttpServer`s. Connections can be |
| 286 * distributed over multiple isolates this way. | 286 * distributed over multiple isolates this way. |
| 287 */ | 287 */ |
| 288 | 288 |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 * ## HTTPS connections | 1233 * ## HTTPS connections |
| 1234 * | 1234 * |
| 1235 * An HttpClient can make HTTPS requests, connecting to a server using | 1235 * An HttpClient can make HTTPS requests, connecting to a server using |
| 1236 * the TLS (SSL) secure networking protocol. Calling [getUrl] with an | 1236 * the TLS (SSL) secure networking protocol. Calling [getUrl] with an |
| 1237 * https: scheme will work automatically, if the server's certificate is | 1237 * https: scheme will work automatically, if the server's certificate is |
| 1238 * signed by a root CA (certificate authority) on the default list of | 1238 * signed by a root CA (certificate authority) on the default list of |
| 1239 * well-known trusted CAs, compiled by Mozilla. | 1239 * well-known trusted CAs, compiled by Mozilla. |
| 1240 * | 1240 * |
| 1241 * To add a custom trusted certificate authority, or to send a client | 1241 * To add a custom trusted certificate authority, or to send a client |
| 1242 * certificate to servers that request one, pass a [SecurityContext] object | 1242 * certificate to servers that request one, pass a [SecurityContext] object |
| 1243 * as the optional [context] argument to the `HttpClient` constructor. | 1243 * as the optional `context` argument to the `HttpClient` constructor. |
| 1244 * The desired security options can be set on the [SecurityContext] object. | 1244 * The desired security options can be set on the [SecurityContext] object. |
| 1245 * | 1245 * |
| 1246 * ## Headers | 1246 * ## Headers |
| 1247 * | 1247 * |
| 1248 * All HttpClient requests set the following header by default: | 1248 * All HttpClient requests set the following header by default: |
| 1249 * | 1249 * |
| 1250 * Accept-Encoding: gzip | 1250 * Accept-Encoding: gzip |
| 1251 * | 1251 * |
| 1252 * This allows the HTTP server to use gzip compression for the body if | 1252 * This allows the HTTP server to use gzip compression for the body if |
| 1253 * possible. If this behavior is not desired set the | 1253 * possible. If this behavior is not desired set the |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 Future<HttpClientRequest> open( | 1358 Future<HttpClientRequest> open( |
| 1359 String method, String host, int port, String path); | 1359 String method, String host, int port, String path); |
| 1360 | 1360 |
| 1361 /** | 1361 /** |
| 1362 * Opens a HTTP connection. | 1362 * Opens a HTTP connection. |
| 1363 * | 1363 * |
| 1364 * The HTTP method is specified in [method] and the URL to use in | 1364 * The HTTP method is specified in [method] and the URL to use in |
| 1365 * [url]. | 1365 * [url]. |
| 1366 * | 1366 * |
| 1367 * The `Host` header for the request will be set to the value | 1367 * The `Host` header for the request will be set to the value |
| 1368 * [host]:[port]. This can be overridden through the | 1368 * [Uri.host]:[Uri.port] from [url]. This can be overridden through the |
| 1369 * [HttpClientRequest] interface before the request is sent. NOTE | 1369 * [HttpClientRequest] interface before the request is sent. NOTE |
| 1370 * if [host] is an IP address this will still be set in the `Host` | 1370 * if [host] is an IP address this will still be set in the `Host` |
| 1371 * header. | 1371 * header. |
| 1372 * | 1372 * |
| 1373 * For additional information on the sequence of events during an | 1373 * For additional information on the sequence of events during an |
| 1374 * HTTP transaction, and the objects returned by the futures, see | 1374 * HTTP transaction, and the objects returned by the futures, see |
| 1375 * the overall documentation for the class [HttpClient]. | 1375 * the overall documentation for the class [HttpClient]. |
| 1376 */ | 1376 */ |
| 1377 Future<HttpClientRequest> openUrl(String method, Uri url); | 1377 Future<HttpClientRequest> openUrl(String method, Uri url); |
| 1378 | 1378 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 * | 1643 * |
| 1644 * If a bad certificate is received on a connection attempt, the library calls | 1644 * If a bad certificate is received on a connection attempt, the library calls |
| 1645 * the function that was the value of badCertificateCallback at the time | 1645 * the function that was the value of badCertificateCallback at the time |
| 1646 * the request is made, even if the value of badCertificateCallback | 1646 * the request is made, even if the value of badCertificateCallback |
| 1647 * has changed since then. | 1647 * has changed since then. |
| 1648 */ | 1648 */ |
| 1649 set badCertificateCallback( | 1649 set badCertificateCallback( |
| 1650 bool callback(X509Certificate cert, String host, int port)); | 1650 bool callback(X509Certificate cert, String host, int port)); |
| 1651 | 1651 |
| 1652 /** | 1652 /** |
| 1653 * Shut down the HTTP client. If [force] is [:false:] (the default) | 1653 * Shut down the HTTP client. If [force] is `false` (the default) |
| 1654 * the [:HttpClient:] will be kept alive until all active | 1654 * the [HttpClient] will be kept alive until all active |
| 1655 * connections are done. If [force] is [:true:] any active | 1655 * connections are done. If [force] is `true` any active |
| 1656 * connections will be closed to immediately release all | 1656 * connections will be closed to immediately release all |
| 1657 * resources. These closed connections will receive an [:onError:] | 1657 * resources. These closed connections will receive an error |
| 1658 * callback to indicate that the client was shut down. In both cases | 1658 * event to indicate that the client was shut down. In both cases |
| 1659 * trying to establish a new connection after calling [close] | 1659 * trying to establish a new connection after calling [close] |
| 1660 * will throw an exception. | 1660 * will throw an exception. |
| 1661 */ | 1661 */ |
| 1662 void close({bool force: false}); | 1662 void close({bool force: false}); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 /** | 1665 /** |
| 1666 * HTTP request for a client connection. | 1666 * HTTP request for a client connection. |
| 1667 * | 1667 * |
| 1668 * To set up a request, set the headers using the headers property | 1668 * To set up a request, set the headers using the headers property |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 * following the redirect. | 1715 * following the redirect. |
| 1716 * | 1716 * |
| 1717 * All headers added to the request will be added to the redirection | 1717 * All headers added to the request will be added to the redirection |
| 1718 * request(s). However, any body send with the request will not be | 1718 * request(s). However, any body send with the request will not be |
| 1719 * part of the redirection request(s). | 1719 * part of the redirection request(s). |
| 1720 */ | 1720 */ |
| 1721 bool followRedirects; | 1721 bool followRedirects; |
| 1722 | 1722 |
| 1723 /** | 1723 /** |
| 1724 * Set this property to the maximum number of redirects to follow | 1724 * Set this property to the maximum number of redirects to follow |
| 1725 * when [followRedirects] is [:true:]. If this number is exceeded the | 1725 * when [followRedirects] is `true`. If this number is exceeded |
| 1726 * [onError] callback will be called with a [RedirectException]. | 1726 * an error event will be added with a [RedirectException]. |
| 1727 * | 1727 * |
| 1728 * The default value is 5. | 1728 * The default value is 5. |
| 1729 */ | 1729 */ |
| 1730 int maxRedirects; | 1730 int maxRedirects; |
| 1731 | 1731 |
| 1732 /** | 1732 /** |
| 1733 * The method of the request. | 1733 * The method of the request. |
| 1734 */ | 1734 */ |
| 1735 String get method; | 1735 String get method; |
| 1736 | 1736 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 * the current response. All body data must have been read from the | 1864 * the current response. All body data must have been read from the |
| 1865 * current response before calling [redirect]. | 1865 * current response before calling [redirect]. |
| 1866 * | 1866 * |
| 1867 * All headers added to the request will be added to the redirection | 1867 * All headers added to the request will be added to the redirection |
| 1868 * request. However, any body sent with the request will not be | 1868 * request. However, any body sent with the request will not be |
| 1869 * part of the redirection request. | 1869 * part of the redirection request. |
| 1870 * | 1870 * |
| 1871 * If [followLoops] is set to [:true:], redirect will follow the redirect, | 1871 * If [followLoops] is set to [:true:], redirect will follow the redirect, |
| 1872 * even if the URL was already visited. The default value is [:false:]. | 1872 * even if the URL was already visited. The default value is [:false:]. |
| 1873 * | 1873 * |
| 1874 * [redirect] will ignore [maxRedirects] and will always perform the redirect. | 1874 * The method will ignore [HttpClientRequest.maxRedirects] |
| 1875 * and will always perform the redirect. |
| 1875 */ | 1876 */ |
| 1876 Future<HttpClientResponse> redirect( | 1877 Future<HttpClientResponse> redirect( |
| 1877 [String method, Uri url, bool followLoops]); | 1878 [String method, Uri url, bool followLoops]); |
| 1878 | 1879 |
| 1879 /** | 1880 /** |
| 1880 * Returns the client response headers. | 1881 * Returns the client response headers. |
| 1881 * | 1882 * |
| 1882 * The client response headers are immutable. | 1883 * The client response headers are immutable. |
| 1883 */ | 1884 */ |
| 1884 HttpHeaders get headers; | 1885 HttpHeaders get headers; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1992 class RedirectException implements HttpException { | 1993 class RedirectException implements HttpException { |
| 1993 final String message; | 1994 final String message; |
| 1994 final List<RedirectInfo> redirects; | 1995 final List<RedirectInfo> redirects; |
| 1995 | 1996 |
| 1996 const RedirectException(this.message, this.redirects); | 1997 const RedirectException(this.message, this.redirects); |
| 1997 | 1998 |
| 1998 String toString() => "RedirectException: $message"; | 1999 String toString() => "RedirectException: $message"; |
| 1999 | 2000 |
| 2000 Uri get uri => redirects.last.location; | 2001 Uri get uri => redirects.last.location; |
| 2001 } | 2002 } |
| OLD | NEW |