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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 * onError: handleError); // listen() failed. | 870 * onError: handleError); // listen() failed. |
871 * }).catchError(handleError); | 871 * }).catchError(handleError); |
872 * | 872 * |
873 * An HttpRequest object provides access to the associated [HttpResponse] | 873 * An HttpRequest object provides access to the associated [HttpResponse] |
874 * object through the response property. | 874 * object through the response property. |
875 * The server writes its response to the body of the HttpResponse object. | 875 * The server writes its response to the body of the HttpResponse object. |
876 * For example, here's a function that responds to a request: | 876 * For example, here's a function that responds to a request: |
877 * | 877 * |
878 * void handleGetRequest(HttpRequest req) { | 878 * void handleGetRequest(HttpRequest req) { |
879 * HttpResponse res = req.response; | 879 * HttpResponse res = req.response; |
880 * var body = []; | 880 * res.write('Received request ${req.method}: ${req.uri.path}'); |
881 * req.listen((List<int> buffer) => body.add(buffer), | 881 * res.close(); |
882 * onDone: () { | |
883 * res.write('Received ${body.length} for request '); | |
884 * res.write(' ${req.method}: ${req.uri.path}'); | |
885 * res.close(); | |
886 * }, | |
887 * onError: handleError); | |
888 * } | 882 * } |
889 */ | 883 */ |
890 abstract class HttpRequest implements Stream<List<int>> { | 884 abstract class HttpRequest implements Stream<List<int>> { |
891 /** | 885 /** |
892 * The content length of the request body. | 886 * The content length of the request body. |
893 * | 887 * |
894 * If the size of the request body is not known in advance, | 888 * If the size of the request body is not known in advance, |
895 * this value is -1. | 889 * this value is -1. |
896 */ | 890 */ |
897 int get contentLength; | 891 int get contentLength; |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 class RedirectException implements HttpException { | 1911 class RedirectException implements HttpException { |
1918 final String message; | 1912 final String message; |
1919 final List<RedirectInfo> redirects; | 1913 final List<RedirectInfo> redirects; |
1920 | 1914 |
1921 const RedirectException(this.message, this.redirects); | 1915 const RedirectException(this.message, this.redirects); |
1922 | 1916 |
1923 String toString() => "RedirectException: $message"; | 1917 String toString() => "RedirectException: $message"; |
1924 | 1918 |
1925 Uri get uri => redirects.last.location; | 1919 Uri get uri => redirects.last.location; |
1926 } | 1920 } |
OLD | NEW |