Chromium Code Reviews| Index: sdk/lib/io/http.dart |
| diff --git a/sdk/lib/io/http.dart b/sdk/lib/io/http.dart |
| index 859803740686bae66ca75c8b87e48fcfc650ba4a..ece0827b6b353a40cfd4d20ea61536feb76497fc 100644 |
| --- a/sdk/lib/io/http.dart |
| +++ b/sdk/lib/io/http.dart |
| @@ -83,6 +83,27 @@ abstract class HttpStatus { |
| */ |
| abstract class HttpServer implements Stream<HttpRequest> { |
| /** |
| + * Set and get the default value of the `Server` header for all responses |
| + * generated by this [HttpServer]. The default value is |
| + * `Dart/<version> (dart:io)`. |
| + * |
| + * If the serverHeader is set to `null`, no default `Server` header will be |
| + * added to each response. |
| + */ |
| + String serverHeader; |
| + |
| + /** |
| + * Get or set the timeout used for idle keep-alive connections. If no further |
| + * request is seen within [idleTimeout] after the previous request was |
| + * completed, the connection is droped. |
|
Lasse Reichstein Nielsen
2014/01/06 09:29:30
droped -> dropped
|
| + * |
| + * Default is 120 seconds. |
| + * |
| + * To disable, set [idleTimeout] to `null`. |
| + */ |
| + Duration idleTimeout; |
| + |
| + /** |
| * Starts listening for HTTP requests on the specified [address] and |
| * [port]. |
| * |
| @@ -205,27 +226,6 @@ abstract class HttpServer implements Stream<HttpRequest> { |
| * current connections handled by the server. |
| */ |
| HttpConnectionsInfo connectionsInfo(); |
| - |
| - /** |
| - * Set and get the default value of the `Server` header for all responses |
| - * generated by this [HttpServer]. The default value is |
| - * `Dart/<version> (dart:io)`. |
| - * |
| - * If the serverHeader is set to `null`, no default `Server` header will be |
| - * added to each response. |
| - */ |
| - String serverHeader; |
| - |
| - /** |
| - * Get or set the timeout used for idle keep-alive connections. If no further |
| - * request is seen within [idleTimeout] after the previous request was |
| - * completed, the connection is droped. |
| - * |
| - * Default is 120 seconds. |
| - * |
| - * To disable, set [idleTimeout] to `null`. |
| - */ |
| - Duration idleTimeout; |
| } |
| @@ -372,6 +372,59 @@ abstract class HttpHeaders { |
| USER_AGENT]; |
| /** |
| + * Gets and sets the date. The value of this property will |
| + * reflect the 'date' header. |
| + */ |
| + DateTime date; |
| + |
| + /** |
| + * Gets and sets the expiry date. The value of this property will |
| + * reflect the 'expires' header. |
| + */ |
| + DateTime expires; |
| + |
| + /** |
| + * Gets and sets the "if-modified-since" date. The value of this property will |
| + * reflect the "if-modified-since" header. |
| + */ |
| + DateTime ifModifiedSince; |
| + |
| + /** |
| + * Gets and sets the host part of the 'host' header for the |
| + * connection. |
| + */ |
| + String host; |
| + |
| + /** |
| + * Gets and sets the port part of the 'host' header for the |
| + * connection. |
| + */ |
| + int port; |
| + |
| + /** |
| + * Gets and sets the content type. Note that the content type in the |
| + * header will only be updated if this field is set |
| + * directly. Mutating the returned current value will have no |
| + * effect. |
| + */ |
| + ContentType contentType; |
| + |
| + /** |
| + * Gets and sets the content length header value. |
| + */ |
| + int contentLength; |
| + |
| + /** |
| + * Gets and sets the persistent connection header value. |
| + */ |
| + bool persistentConnection; |
| + |
| + /** |
| + * Gets and sets the chunked transfer encoding header value. |
| + */ |
| + bool chunkedTransferEncoding; |
| + |
| + /** |
| * Returns the list of values for the header named [name]. If there |
| * is no header with the provided name, [:null:] will be returned. |
| */ |
| @@ -431,59 +484,6 @@ abstract class HttpHeaders { |
| * 'set-cookie' header has folding disabled by default. |
| */ |
| void noFolding(String name); |
| - |
| - /** |
| - * Gets and sets the date. The value of this property will |
| - * reflect the 'date' header. |
| - */ |
| - DateTime date; |
| - |
| - /** |
| - * Gets and sets the expiry date. The value of this property will |
| - * reflect the 'expires' header. |
| - */ |
| - DateTime expires; |
| - |
| - /** |
| - * Gets and sets the "if-modified-since" date. The value of this property will |
| - * reflect the "if-modified-since" header. |
| - */ |
| - DateTime ifModifiedSince; |
| - |
| - /** |
| - * Gets and sets the host part of the 'host' header for the |
| - * connection. |
| - */ |
| - String host; |
| - |
| - /** |
| - * Gets and sets the port part of the 'host' header for the |
| - * connection. |
| - */ |
| - int port; |
| - |
| - /** |
| - * Gets and sets the content type. Note that the content type in the |
| - * header will only be updated if this field is set |
| - * directly. Mutating the returned current value will have no |
| - * effect. |
| - */ |
| - ContentType contentType; |
| - |
| - /** |
| - * Gets and sets the content length header value. |
| - */ |
| - int contentLength; |
| - |
| - /** |
| - * Gets and sets the persistent connection header value. |
| - */ |
| - bool persistentConnection; |
| - |
| - /** |
| - * Gets and sets the chunked transfer encoding header value. |
| - */ |
| - bool chunkedTransferEncoding; |
| } |
| @@ -647,19 +647,6 @@ abstract class ContentType implements HeaderValue { |
| */ |
| abstract class Cookie { |
| /** |
| - * Creates a new cookie optionally setting the name and value. |
| - */ |
| - factory Cookie([String name, String value]) => new _Cookie(name, value); |
| - |
| - /** |
| - * Creates a new cookie by parsing a header value from a 'set-cookie' |
| - * header. |
| - */ |
| - factory Cookie.fromSetCookieValue(String value) { |
| - return new _Cookie.fromSetCookieValue(value); |
| - } |
| - |
| - /** |
| * Gets and sets the name. |
| */ |
| String name; |
| @@ -701,6 +688,19 @@ abstract class Cookie { |
| bool httpOnly; |
| /** |
| + * Creates a new cookie optionally setting the name and value. |
| + */ |
| + factory Cookie([String name, String value]) => new _Cookie(name, value); |
| + |
| + /** |
| + * Creates a new cookie by parsing a header value from a 'set-cookie' |
| + * header. |
| + */ |
| + factory Cookie.fromSetCookieValue(String value) { |
| + return new _Cookie.fromSetCookieValue(value); |
| + } |
| + |
| + /** |
| * Returns the formatted string representation of the cookie. The |
| * string representation can be used for for setting the Cookie or |
| * 'set-cookie' headers |
| @@ -738,16 +738,16 @@ abstract class Cookie { |
| * HttpServer.bind(HOST, PORT).then((_server) { |
| * _server.listen((HttpRequest request) { |
| * switch (request.method) { |
| - * case 'GET': |
| + * case 'GET': |
| * handleGetRequest(request); |
| * break; |
| - * case 'POST': |
| + * case 'POST': |
| * ... |
| * } |
| * }, |
| * onError: handleError); // listen() failed. |
| * }).catchError(handleError); |
| - * |
| + * |
| * Listen to the HttpRequest stream to handle the |
| * data and be notified once the entire body is received. |
| * An HttpRequest object contains an [HttpResponse] object, |
| @@ -824,7 +824,7 @@ abstract class HttpRequest implements Stream<List<int>> { |
| HttpSession get session; |
| /** |
| - * The HTTP protocol version used in the request, |
| + * The HTTP protocol version used in the request, |
| * either "1.0" or "1.1" (read-only). |
| */ |
| String get protocolVersion; |
| @@ -1330,6 +1330,41 @@ abstract class HttpClient { |
| */ |
| abstract class HttpClientRequest implements IOSink { |
| /** |
| + * Gets and sets the requested persistent connection state. |
| + * The default value is [:true:]. |
| + */ |
| + bool persistentConnection; |
| + |
| + /** |
| + * Set this property to [:true:] if this request should |
| + * automatically follow redirects. The default is [:true:]. |
| + * |
| + * Automatic redirect will only happen for "GET" and "HEAD" requests |
| + * and only for the status codes [:HttpHeaders.MOVED_PERMANENTLY:] |
| + * (301), [:HttpStatus.FOUND:] (302), |
| + * [:HttpStatus.MOVED_TEMPORARILY:] (302, alias for |
| + * [:HttpStatus.FOUND:]), [:HttpStatus.SEE_OTHER:] (303) and |
| + * [:HttpStatus.TEMPORARY_REDIRECT:] (307). For |
| + * [:HttpStatus.SEE_OTHER:] (303) autmatic redirect will also happen |
| + * for "POST" requests with the method changed to "GET" when |
| + * following the redirect. |
| + * |
| + * All headers added to the request will be added to the redirection |
| + * request(s). However, any body send with the request will not be |
| + * part of the redirection request(s). |
| + */ |
| + bool followRedirects; |
| + |
| + /** |
| + * Set this property to the maximum number of redirects to follow |
| + * when [followRedirects] is [:true:]. If this number is exceeded the |
| + * [onError] callback will be called with a [RedirectException]. |
| + * |
| + * The default value is 5. |
| + */ |
| + int maxRedirects; |
| + |
| + /** |
| * The method of the request. |
| */ |
| String get method; |
| @@ -1357,12 +1392,6 @@ abstract class HttpClientRequest implements IOSink { |
| List<Cookie> get cookies; |
| /** |
| - * Gets and sets the requested persistent connection state. |
| - * The default value is [:true:]. |
| - */ |
| - bool persistentConnection; |
| - |
| - /** |
| * A [HttpClientResponse] future that will complete once the response is |
| * available. If an error occurs before the response is available, this |
| * future will complete with an error. |
| @@ -1375,35 +1404,6 @@ abstract class HttpClientRequest implements IOSink { |
| Future<HttpClientResponse> close(); |
| /** |
| - * Set this property to [:true:] if this request should |
| - * automatically follow redirects. The default is [:true:]. |
| - * |
| - * Automatic redirect will only happen for "GET" and "HEAD" requests |
| - * and only for the status codes [:HttpHeaders.MOVED_PERMANENTLY:] |
| - * (301), [:HttpStatus.FOUND:] (302), |
| - * [:HttpStatus.MOVED_TEMPORARILY:] (302, alias for |
| - * [:HttpStatus.FOUND:]), [:HttpStatus.SEE_OTHER:] (303) and |
| - * [:HttpStatus.TEMPORARY_REDIRECT:] (307). For |
| - * [:HttpStatus.SEE_OTHER:] (303) autmatic redirect will also happen |
| - * for "POST" requests with the method changed to "GET" when |
| - * following the redirect. |
| - * |
| - * All headers added to the request will be added to the redirection |
| - * request(s). However, any body send with the request will not be |
| - * part of the redirection request(s). |
| - */ |
| - bool followRedirects; |
| - |
| - /** |
| - * Set this property to the maximum number of redirects to follow |
| - * when [followRedirects] is [:true:]. If this number is exceeded the |
| - * [onError] callback will be called with a [RedirectException]. |
| - * |
| - * The default value is 5. |
| - */ |
| - int maxRedirects; |
| - |
| - /** |
| * Get information about the client connection. Returns [null] if the socket |
| * is not available. |
| */ |
| @@ -1584,9 +1584,9 @@ class HttpException implements IOException { |
| const HttpException(String this.message, {Uri this.uri}); |
| String toString() { |
| - var b = new StringBuffer(); |
| - b.write('HttpException: '); |
| - b.write(message); |
| + var b = new StringBuffer() |
| + ..write('HttpException: ') |
|
Lasse Reichstein Nielsen
2014/01/06 09:29:30
Indent by 4.
|
| + ..write(message); |
| if (uri != null) { |
| b.write(', uri = $uri'); |
| } |
| @@ -1599,8 +1599,7 @@ class RedirectException implements HttpException { |
| final String message; |
| final List<RedirectInfo> redirects; |
| - const RedirectException(String this.message, |
| - List<RedirectInfo> this.redirects); |
| + const RedirectException(this.message, this.redirects); |
| String toString() => "RedirectException: $message"; |