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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
839 | 839 |
840 /** | 840 /** |
841 * The HTTP protocol version used in the request, | 841 * The HTTP protocol version used in the request, |
842 * either "1.0" or "1.1" (read-only). | 842 * either "1.0" or "1.1" (read-only). |
843 */ | 843 */ |
844 String get protocolVersion; | 844 String get protocolVersion; |
845 | 845 |
846 /** | 846 /** |
847 * Information about the client connection (read-only). | 847 * Information about the client connection (read-only). |
848 * | 848 * |
849 * Returns [null] if the socket is not available. | 849 * Returns [:null:] if the socket is not available. |
850 */ | 850 */ |
851 HttpConnectionInfo get connectionInfo; | 851 HttpConnectionInfo get connectionInfo; |
852 | 852 |
853 /** | 853 /** |
854 * The [HttpResponse] object, used for sending back the response to the | 854 * The [HttpResponse] object, used for sending back the response to the |
855 * client (read-only). | 855 * client (read-only). |
856 * | 856 * |
857 * If the [contentLength] of the body isn't 0, and the body isn't being read, | 857 * If the [contentLength] of the body isn't 0, and the body isn't being read, |
858 * any write calls on the [HttpResponse] automatically drain the request | 858 * any write calls on the [HttpResponse] automatically drain the request |
859 * body. | 859 * body. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
963 * Detaches the underlying socket from the HTTP server. When the | 963 * Detaches the underlying socket from the HTTP server. When the |
964 * socket is detached the HTTP server will no longer perform any | 964 * socket is detached the HTTP server will no longer perform any |
965 * operations on it. | 965 * operations on it. |
966 * | 966 * |
967 * This is normally used when a HTTP upgrade request is received | 967 * This is normally used when a HTTP upgrade request is received |
968 * and the communication should continue with a different protocol. | 968 * and the communication should continue with a different protocol. |
969 */ | 969 */ |
970 Future<Socket> detachSocket(); | 970 Future<Socket> detachSocket(); |
971 | 971 |
972 /** | 972 /** |
973 * Gets information about the client connection. Returns [null] if the socket | 973 * Gets information about the client connection. Returns [:null:] if the socke t |
Lasse Reichstein Nielsen
2014/01/19 12:40:30
Long line.
(I guess that's the primary reason for
kevmoo
2014/01/19 19:22:54
Done.
| |
974 * is not available. | 974 * is not available. |
975 */ | 975 */ |
976 HttpConnectionInfo get connectionInfo; | 976 HttpConnectionInfo get connectionInfo; |
977 } | 977 } |
978 | 978 |
979 | 979 |
980 /** | 980 /** |
981 * A client that receives content, such as web pages, from | 981 * A client that receives content, such as web pages, from |
982 * a server using the HTTP protocol. | 982 * a server using the HTTP protocol. |
983 * | 983 * |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 */ | 1139 */ |
1140 Future<HttpClientRequest> postUrl(Uri url); | 1140 Future<HttpClientRequest> postUrl(Uri url); |
1141 | 1141 |
1142 /** | 1142 /** |
1143 * Sets the function to be called when a site is requesting | 1143 * Sets the function to be called when a site is requesting |
1144 * authentication. The URL requested and the security realm from the | 1144 * authentication. The URL requested and the security realm from the |
1145 * server are passed in the arguments [url] and [realm]. | 1145 * server are passed in the arguments [url] and [realm]. |
1146 * | 1146 * |
1147 * The function returns a [Future] which should complete when the | 1147 * The function returns a [Future] which should complete when the |
1148 * authentication has been resolved. If credentials cannot be | 1148 * authentication has been resolved. If credentials cannot be |
1149 * provided the [Future] should complete with [false]. If | 1149 * provided the [Future] should complete with [:false:]. If |
1150 * credentials are available the function should add these using | 1150 * credentials are available the function should add these using |
1151 * [addCredentials] before completing the [Future] with the value | 1151 * [addCredentials] before completing the [Future] with the value |
1152 * [true]. | 1152 * [:true:]. |
1153 * | 1153 * |
1154 * If the [Future] completes with true the request will be retried | 1154 * If the [Future] completes with true the request will be retried |
1155 * using the updated credentials. Otherwise response processing will | 1155 * using the updated credentials. Otherwise response processing will |
1156 * continue normally. | 1156 * continue normally. |
1157 */ | 1157 */ |
1158 set authenticate(Future<bool> f(Uri url, String scheme, String realm)); | 1158 set authenticate(Future<bool> f(Uri url, String scheme, String realm)); |
1159 | 1159 |
1160 /** | 1160 /** |
1161 * Add credentials to be used for authorizing HTTP requests. | 1161 * Add credentials to be used for authorizing HTTP requests. |
1162 */ | 1162 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1246 } | 1246 } |
1247 | 1247 |
1248 /** | 1248 /** |
1249 * Sets the function to be called when a proxy is requesting | 1249 * Sets the function to be called when a proxy is requesting |
1250 * authentication. Information on the proxy in use and the security | 1250 * authentication. Information on the proxy in use and the security |
1251 * realm for the authentication are passed in the arguments [host], | 1251 * realm for the authentication are passed in the arguments [host], |
1252 * [port] and [realm]. | 1252 * [port] and [realm]. |
1253 * | 1253 * |
1254 * The function returns a [Future] which should complete when the | 1254 * The function returns a [Future] which should complete when the |
1255 * authentication has been resolved. If credentials cannot be | 1255 * authentication has been resolved. If credentials cannot be |
1256 * provided the [Future] should complete with [false]. If | 1256 * provided the [Future] should complete with [:false:]. If |
1257 * credentials are available the function should add these using | 1257 * credentials are available the function should add these using |
1258 * [addProxyCredentials] before completing the [Future] with the value | 1258 * [addProxyCredentials] before completing the [Future] with the value |
1259 * [true]. | 1259 * [:true:]. |
1260 * | 1260 * |
1261 * If the [Future] completes with [true] the request will be retried | 1261 * If the [Future] completes with [:true:] the request will be retried |
1262 * using the updated credentials. Otherwise response processing will | 1262 * using the updated credentials. Otherwise response processing will |
1263 * continue normally. | 1263 * continue normally. |
1264 */ | 1264 */ |
1265 set authenticateProxy( | 1265 set authenticateProxy( |
1266 Future<bool> f(String host, int port, String scheme, String realm)); | 1266 Future<bool> f(String host, int port, String scheme, String realm)); |
1267 | 1267 |
1268 /** | 1268 /** |
1269 * Add credentials to be used for authorizing HTTP proxies. | 1269 * Add credentials to be used for authorizing HTTP proxies. |
1270 */ | 1270 */ |
1271 void addProxyCredentials(String host, | 1271 void addProxyCredentials(String host, |
1272 int port, | 1272 int port, |
1273 String realm, | 1273 String realm, |
1274 HttpClientCredentials credentials); | 1274 HttpClientCredentials credentials); |
1275 | 1275 |
1276 /** | 1276 /** |
1277 * Sets a callback that will decide whether to accept a secure connection | 1277 * Sets a callback that will decide whether to accept a secure connection |
1278 * with a server certificate that cannot be authenticated by any of our | 1278 * with a server certificate that cannot be authenticated by any of our |
1279 * trusted root certificates. | 1279 * trusted root certificates. |
1280 * | 1280 * |
1281 * When an secure HTTP request if made, using this HttpClient, and the | 1281 * When an secure HTTP request if made, using this HttpClient, and the |
1282 * server returns a server certificate that cannot be authenticated, the | 1282 * server returns a server certificate that cannot be authenticated, the |
1283 * callback is called asynchronously with the [X509Certificate] object and | 1283 * callback is called asynchronously with the [X509Certificate] object and |
1284 * the server's hostname and port. If the value of [badCertificateCallback] | 1284 * the server's hostname and port. If the value of [badCertificateCallback] |
1285 * is [null], the bad certificate is rejected, as if the callback | 1285 * is [:null:], the bad certificate is rejected, as if the callback |
1286 * returned [false] | 1286 * returned [:false:] |
1287 * | 1287 * |
1288 * If the callback returns true, the secure connection is accepted and the | 1288 * If the callback returns true, the secure connection is accepted and the |
1289 * [:Future<HttpClientRequest>:] that was returned from the call making the | 1289 * [:Future<HttpClientRequest>:] that was returned from the call making the |
1290 * request completes with a valid HttpRequest object. If the callback returns | 1290 * request completes with a valid HttpRequest object. If the callback returns |
1291 * false, the [:Future<HttpClientRequest>:] completes with an exception. | 1291 * false, the [:Future<HttpClientRequest>:] completes with an exception. |
1292 * | 1292 * |
1293 * If a bad certificate is received on a connection attempt, the library calls | 1293 * If a bad certificate is received on a connection attempt, the library calls |
1294 * the function that was the value of badCertificateCallback at the time | 1294 * the function that was the value of badCertificateCallback at the time |
1295 * the the request is made, even if the value of badCertificateCallback | 1295 * the the request is made, even if the value of badCertificateCallback |
1296 * has changed since then. | 1296 * has changed since then. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1411 * future will complete with an error. | 1411 * future will complete with an error. |
1412 */ | 1412 */ |
1413 Future<HttpClientResponse> get done; | 1413 Future<HttpClientResponse> get done; |
1414 | 1414 |
1415 /** | 1415 /** |
1416 * Close the request for input. Returns the value of [done]. | 1416 * Close the request for input. Returns the value of [done]. |
1417 */ | 1417 */ |
1418 Future<HttpClientResponse> close(); | 1418 Future<HttpClientResponse> close(); |
1419 | 1419 |
1420 /** | 1420 /** |
1421 * Get information about the client connection. Returns [null] if the socket | 1421 * Get information about the client connection. Returns [:null:] if the socket |
1422 * is not available. | 1422 * is not available. |
1423 */ | 1423 */ |
1424 HttpConnectionInfo get connectionInfo; | 1424 HttpConnectionInfo get connectionInfo; |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 /** | 1428 /** |
1429 * HTTP response for a client connection. The [HttpClientResponse] is a | 1429 * HTTP response for a client connection. The [HttpClientResponse] is a |
1430 * [Stream] of the body content of the response. Listen to the body to handle | 1430 * [Stream] of the body content of the response. Listen to the body to handle |
1431 * the data and be notified once the entire body is received. | 1431 * the data and be notified once the entire body is received. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1471 * Redirects this connection to a new URL. The default value for | 1471 * Redirects this connection to a new URL. The default value for |
1472 * [method] is the method for the current request. The default value | 1472 * [method] is the method for the current request. The default value |
1473 * for [url] is the value of the [HttpHeaders.LOCATION] header of | 1473 * for [url] is the value of the [HttpHeaders.LOCATION] header of |
1474 * the current response. All body data must have been read from the | 1474 * the current response. All body data must have been read from the |
1475 * current response before calling [redirect]. | 1475 * current response before calling [redirect]. |
1476 * | 1476 * |
1477 * All headers added to the request will be added to the redirection | 1477 * All headers added to the request will be added to the redirection |
1478 * request. However, any body sent with the request will not be | 1478 * request. However, any body sent with the request will not be |
1479 * part of the redirection request. | 1479 * part of the redirection request. |
1480 * | 1480 * |
1481 * If [followLoops] is set to [true], redirect will follow the redirect, | 1481 * If [followLoops] is set to [:true:], redirect will follow the redirect, |
1482 * even if the URL was already visited. The default value is [false]. | 1482 * even if the URL was already visited. The default value is [:false:]. |
1483 * | 1483 * |
1484 * [redirect] will ignore [maxRedirects] and will always perform the redirect. | 1484 * [redirect] will ignore [maxRedirects] and will always perform the redirect. |
1485 */ | 1485 */ |
1486 Future<HttpClientResponse> redirect([String method, | 1486 Future<HttpClientResponse> redirect([String method, |
1487 Uri url, | 1487 Uri url, |
1488 bool followLoops]); | 1488 bool followLoops]); |
1489 | 1489 |
1490 | 1490 |
1491 /** | 1491 /** |
1492 * Returns the response headers. | 1492 * Returns the response headers. |
(...skipping 15 matching lines...) Expand all Loading... | |
1508 */ | 1508 */ |
1509 List<Cookie> get cookies; | 1509 List<Cookie> get cookies; |
1510 | 1510 |
1511 /** | 1511 /** |
1512 * Returns the certificate of the HTTPS server providing the response. | 1512 * Returns the certificate of the HTTPS server providing the response. |
1513 * Returns null if the connection is not a secure TLS or SSL connection. | 1513 * Returns null if the connection is not a secure TLS or SSL connection. |
1514 */ | 1514 */ |
1515 X509Certificate get certificate; | 1515 X509Certificate get certificate; |
1516 | 1516 |
1517 /** | 1517 /** |
1518 * Gets information about the client connection. Returns [null] if the socket | 1518 * Gets information about the client connection. Returns [:null:] if the socke t |
1519 * is not available. | 1519 * is not available. |
1520 */ | 1520 */ |
1521 HttpConnectionInfo get connectionInfo; | 1521 HttpConnectionInfo get connectionInfo; |
1522 } | 1522 } |
1523 | 1523 |
1524 | 1524 |
1525 abstract class HttpClientCredentials { } | 1525 abstract class HttpClientCredentials { } |
1526 | 1526 |
1527 | 1527 |
1528 /** | 1528 /** |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1612 class RedirectException implements HttpException { | 1612 class RedirectException implements HttpException { |
1613 final String message; | 1613 final String message; |
1614 final List<RedirectInfo> redirects; | 1614 final List<RedirectInfo> redirects; |
1615 | 1615 |
1616 const RedirectException(this.message, this.redirects); | 1616 const RedirectException(this.message, this.redirects); |
1617 | 1617 |
1618 String toString() => "RedirectException: $message"; | 1618 String toString() => "RedirectException: $message"; |
1619 | 1619 |
1620 Uri get uri => redirects.last.location; | 1620 Uri get uri => redirects.last.location; |
1621 } | 1621 } |
OLD | NEW |