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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 * | 168 * |
169 * Default is 120 seconds. | 169 * Default is 120 seconds. |
170 * | 170 * |
171 * Note that it may take up to `2 * idleTimeout` before a idle connection is | 171 * Note that it may take up to `2 * idleTimeout` before a idle connection is |
172 * aborted. | 172 * aborted. |
173 * | 173 * |
174 * To disable, set [idleTimeout] to `null`. | 174 * To disable, set [idleTimeout] to `null`. |
175 */ | 175 */ |
176 Duration idleTimeout; | 176 Duration idleTimeout; |
177 | 177 |
| 178 |
178 /** | 179 /** |
179 * Starts listening for HTTP requests on the specified [address] and | 180 * Starts listening for HTTP requests on the specified [address] and |
180 * [port]. | 181 * [port]. |
181 * | 182 * |
182 * The [address] can either be a [String] or an | 183 * The [address] can either be a [String] or an |
183 * [InternetAddress]. If [address] is a [String], [bind] will | 184 * [InternetAddress]. If [address] is a [String], [bind] will |
184 * perform a [InternetAddress.lookup] and use the first value in the | 185 * perform a [InternetAddress.lookup] and use the first value in the |
185 * list. To listen on the loopback adapter, which will allow only | 186 * list. To listen on the loopback adapter, which will allow only |
186 * incoming connections from the local host, use the value | 187 * incoming connections from the local host, use the value |
187 * [InternetAddress.LOOPBACK_IP_V4] or | 188 * [InternetAddress.LOOPBACK_IP_V4] or |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 * When a deadline is exceeded, the response will be closed and any further | 1077 * When a deadline is exceeded, the response will be closed and any further |
1077 * data ignored. | 1078 * data ignored. |
1078 * | 1079 * |
1079 * To disable a deadline, set the [deadline] to `null`. | 1080 * To disable a deadline, set the [deadline] to `null`. |
1080 * | 1081 * |
1081 * The [deadline] is `null` by default. | 1082 * The [deadline] is `null` by default. |
1082 */ | 1083 */ |
1083 Duration deadline; | 1084 Duration deadline; |
1084 | 1085 |
1085 /** | 1086 /** |
| 1087 * Get or set if the [HttpResponse] should buffer output. |
| 1088 * |
| 1089 * Default value is `true`. |
| 1090 * |
| 1091 * __Note__: Disabling buffering of the output can result in very poor |
| 1092 * performance, when writing many small chunks. |
| 1093 */ |
| 1094 bool bufferOutput; |
| 1095 |
| 1096 /** |
1086 * Returns the response headers. | 1097 * Returns the response headers. |
1087 * | 1098 * |
1088 * The response headers can be modified until the response body is | 1099 * The response headers can be modified until the response body is |
1089 * written to or closed. After that they become immutable. | 1100 * written to or closed. After that they become immutable. |
1090 */ | 1101 */ |
1091 HttpHeaders get headers; | 1102 HttpHeaders get headers; |
1092 | 1103 |
1093 /** | 1104 /** |
1094 * Cookies to set in the client (in the 'set-cookie' header). | 1105 * Cookies to set in the client (in the 'set-cookie' header). |
1095 */ | 1106 */ |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 Uri get uri; | 1568 Uri get uri; |
1558 | 1569 |
1559 /** | 1570 /** |
1560 * Gets and sets the content length of the request. If the size of | 1571 * Gets and sets the content length of the request. If the size of |
1561 * the request is not known in advance set content length to -1, | 1572 * the request is not known in advance set content length to -1, |
1562 * which is also the default. | 1573 * which is also the default. |
1563 */ | 1574 */ |
1564 int contentLength; | 1575 int contentLength; |
1565 | 1576 |
1566 /** | 1577 /** |
| 1578 * Get or set if the [HttpClientRequest] should buffer output. |
| 1579 * |
| 1580 * Default value is `true`. |
| 1581 * |
| 1582 * __Note__: Disabling buffering of the output can result in very poor |
| 1583 * performance, when writing many small chunks. |
| 1584 */ |
| 1585 bool bufferOutput; |
| 1586 |
| 1587 /** |
1567 * Returns the client request headers. | 1588 * Returns the client request headers. |
1568 * | 1589 * |
1569 * The client request headers can be modified until the client | 1590 * The client request headers can be modified until the client |
1570 * request body is written to or closed. After that they become | 1591 * request body is written to or closed. After that they become |
1571 * immutable. | 1592 * immutable. |
1572 */ | 1593 */ |
1573 HttpHeaders get headers; | 1594 HttpHeaders get headers; |
1574 | 1595 |
1575 /** | 1596 /** |
1576 * Cookies to present to the server (in the 'cookie' header). | 1597 * Cookies to present to the server (in the 'cookie' header). |
(...skipping 21 matching lines...) Expand all Loading... |
1598 | 1619 |
1599 | 1620 |
1600 /** | 1621 /** |
1601 * HTTP response for a client connection. | 1622 * HTTP response for a client connection. |
1602 | 1623 |
1603 * The body of a [HttpClientResponse] object is a | 1624 * The body of a [HttpClientResponse] object is a |
1604 * [Stream] of data from the server. Listen to the body to handle | 1625 * [Stream] of data from the server. Listen to the body to handle |
1605 * the data and be notified when the entire body is received. | 1626 * the data and be notified when the entire body is received. |
1606 * | 1627 * |
1607 * new HttpClient().get('localhost', 80, '/file.txt') | 1628 * new HttpClient().get('localhost', 80, '/file.txt') |
1608 * .then((HttpClientRequeset request) => request.close()) | 1629 * .then((HttpClientRequest request) => request.close()) |
1609 * .then((HttpClientResponse response) { | 1630 * .then((HttpClientResponse response) { |
1610 * response.transform(UTF8.decoder).listen((contents) { | 1631 * response.transform(UTF8.decoder).listen((contents) { |
1611 * // handle data | 1632 * // handle data |
1612 * }); | 1633 * }); |
1613 * }); | 1634 * }); |
1614 */ | 1635 */ |
1615 abstract class HttpClientResponse implements Stream<List<int>> { | 1636 abstract class HttpClientResponse implements Stream<List<int>> { |
1616 /** | 1637 /** |
1617 * Returns the status code. | 1638 * Returns the status code. |
1618 * | 1639 * |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 class RedirectException implements HttpException { | 1833 class RedirectException implements HttpException { |
1813 final String message; | 1834 final String message; |
1814 final List<RedirectInfo> redirects; | 1835 final List<RedirectInfo> redirects; |
1815 | 1836 |
1816 const RedirectException(this.message, this.redirects); | 1837 const RedirectException(this.message, this.redirects); |
1817 | 1838 |
1818 String toString() => "RedirectException: $message"; | 1839 String toString() => "RedirectException: $message"; |
1819 | 1840 |
1820 Uri get uri => redirects.last.location; | 1841 Uri get uri => redirects.last.location; |
1821 } | 1842 } |
OLD | NEW |