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 | |
179 /** | |
180 * Get or set if the HttpServer should buffer output, by default. | |
181 * | |
182 * This setting is also changable at the individual [HttpResponse]s. | |
183 * | |
184 * Default is `true`. | |
185 * | |
186 * __Note__: Disabling buffering of the output can result in very poor | |
187 * performance, when writing many small chunks. | |
188 */ | |
189 bool bufferOutput; | |
Søren Gjesse
2014/04/08 11:54:25
Do we need this default? I assume this will only b
Anders Johnsen
2014/04/08 12:40:07
Good point. Will remove this one.
| |
190 | |
191 | |
178 /** | 192 /** |
179 * Starts listening for HTTP requests on the specified [address] and | 193 * Starts listening for HTTP requests on the specified [address] and |
180 * [port]. | 194 * [port]. |
181 * | 195 * |
182 * The [address] can either be a [String] or an | 196 * The [address] can either be a [String] or an |
183 * [InternetAddress]. If [address] is a [String], [bind] will | 197 * [InternetAddress]. If [address] is a [String], [bind] will |
184 * perform a [InternetAddress.lookup] and use the first value in the | 198 * perform a [InternetAddress.lookup] and use the first value in the |
185 * list. To listen on the loopback adapter, which will allow only | 199 * list. To listen on the loopback adapter, which will allow only |
186 * incoming connections from the local host, use the value | 200 * incoming connections from the local host, use the value |
187 * [InternetAddress.LOOPBACK_IP_V4] or | 201 * [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 | 1090 * When a deadline is exceeded, the response will be closed and any further |
1077 * data ignored. | 1091 * data ignored. |
1078 * | 1092 * |
1079 * To disable a deadline, set the [deadline] to `null`. | 1093 * To disable a deadline, set the [deadline] to `null`. |
1080 * | 1094 * |
1081 * The [deadline] is `null` by default. | 1095 * The [deadline] is `null` by default. |
1082 */ | 1096 */ |
1083 Duration deadline; | 1097 Duration deadline; |
1084 | 1098 |
1085 /** | 1099 /** |
1100 * Get or set if the [HttpResponse] should buffer output. | |
1101 * | |
1102 * Default value is that of [HttpServer.bufferOutput]. | |
1103 * | |
1104 * __Note__: Disabling buffering of the output can result in very poor | |
1105 * performance, when writing many small chunks. | |
1106 */ | |
1107 bool bufferOutput; | |
1108 | |
1109 /** | |
1086 * Returns the response headers. | 1110 * Returns the response headers. |
1087 * | 1111 * |
1088 * The response headers can be modified until the response body is | 1112 * The response headers can be modified until the response body is |
1089 * written to or closed. After that they become immutable. | 1113 * written to or closed. After that they become immutable. |
1090 */ | 1114 */ |
1091 HttpHeaders get headers; | 1115 HttpHeaders get headers; |
1092 | 1116 |
1093 /** | 1117 /** |
1094 * Cookies to set in the client (in the 'set-cookie' header). | 1118 * Cookies to set in the client (in the 'set-cookie' header). |
1095 */ | 1119 */ |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 Uri get uri; | 1581 Uri get uri; |
1558 | 1582 |
1559 /** | 1583 /** |
1560 * Gets and sets the content length of the request. If the size of | 1584 * 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, | 1585 * the request is not known in advance set content length to -1, |
1562 * which is also the default. | 1586 * which is also the default. |
1563 */ | 1587 */ |
1564 int contentLength; | 1588 int contentLength; |
1565 | 1589 |
1566 /** | 1590 /** |
1591 * Get or set if the [HttpClientRequest] should buffer output. | |
1592 * | |
1593 * Default value is `true`. | |
1594 * | |
1595 * __Note__: Disabling buffering of the output can result in very poor | |
1596 * performance, when writing many small chunks. | |
1597 */ | |
1598 bool bufferOutput; | |
1599 | |
1600 /** | |
1567 * Returns the client request headers. | 1601 * Returns the client request headers. |
1568 * | 1602 * |
1569 * The client request headers can be modified until the client | 1603 * The client request headers can be modified until the client |
1570 * request body is written to or closed. After that they become | 1604 * request body is written to or closed. After that they become |
1571 * immutable. | 1605 * immutable. |
1572 */ | 1606 */ |
1573 HttpHeaders get headers; | 1607 HttpHeaders get headers; |
1574 | 1608 |
1575 /** | 1609 /** |
1576 * Cookies to present to the server (in the 'cookie' header). | 1610 * Cookies to present to the server (in the 'cookie' header). |
(...skipping 21 matching lines...) Expand all Loading... | |
1598 | 1632 |
1599 | 1633 |
1600 /** | 1634 /** |
1601 * HTTP response for a client connection. | 1635 * HTTP response for a client connection. |
1602 | 1636 |
1603 * The body of a [HttpClientResponse] object is a | 1637 * The body of a [HttpClientResponse] object is a |
1604 * [Stream] of data from the server. Listen to the body to handle | 1638 * [Stream] of data from the server. Listen to the body to handle |
1605 * the data and be notified when the entire body is received. | 1639 * the data and be notified when the entire body is received. |
1606 * | 1640 * |
1607 * new HttpClient().get('localhost', 80, '/file.txt') | 1641 * new HttpClient().get('localhost', 80, '/file.txt') |
1608 * .then((HttpClientRequeset request) => request.close()) | 1642 * .then((HttpClientRequest request) => request.close()) |
1609 * .then((HttpClientResponse response) { | 1643 * .then((HttpClientResponse response) { |
1610 * response.transform(UTF8.decoder).listen((contents) { | 1644 * response.transform(UTF8.decoder).listen((contents) { |
1611 * // handle data | 1645 * // handle data |
1612 * }); | 1646 * }); |
1613 * }); | 1647 * }); |
1614 */ | 1648 */ |
1615 abstract class HttpClientResponse implements Stream<List<int>> { | 1649 abstract class HttpClientResponse implements Stream<List<int>> { |
1616 /** | 1650 /** |
1617 * Returns the status code. | 1651 * Returns the status code. |
1618 * | 1652 * |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1812 class RedirectException implements HttpException { | 1846 class RedirectException implements HttpException { |
1813 final String message; | 1847 final String message; |
1814 final List<RedirectInfo> redirects; | 1848 final List<RedirectInfo> redirects; |
1815 | 1849 |
1816 const RedirectException(this.message, this.redirects); | 1850 const RedirectException(this.message, this.redirects); |
1817 | 1851 |
1818 String toString() => "RedirectException: $message"; | 1852 String toString() => "RedirectException: $message"; |
1819 | 1853 |
1820 Uri get uri => redirects.last.location; | 1854 Uri get uri => redirects.last.location; |
1821 } | 1855 } |
OLD | NEW |