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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 /** | 669 /** |
670 * Gets the [HttpResponse] object, used for sending back the response to the | 670 * Gets the [HttpResponse] object, used for sending back the response to the |
671 * client. | 671 * client. |
672 */ | 672 */ |
673 HttpResponse get response; | 673 HttpResponse get response; |
674 } | 674 } |
675 | 675 |
676 | 676 |
677 /** | 677 /** |
678 * HTTP response to be send back to the client. | 678 * HTTP response to be send back to the client. |
| 679 * |
| 680 * This object has a number of properties for setting up the HTTP |
| 681 * header of the response. When the header has been set up the methods |
| 682 * from the [IOSink] can be used to write the actual body of the HTTP |
| 683 * response. When one of the [IOSink] methods is used for the |
| 684 * first time the request header is send. Calling any methods that |
| 685 * will change the header after it is sent will throw an exception. |
| 686 * |
| 687 * When writing string data through the [IOSink] the encoding used |
| 688 * will be determined from the "charset" parameter of the |
| 689 * "Content-Type" header. |
| 690 * |
| 691 * HttpResponse response = ... |
| 692 * response.headers.contentType |
| 693 * = new ContentType("application", "json", charset: "utf-8"); |
| 694 * response.write(...); // Strings written will be UTF-8 encoded. |
| 695 * |
| 696 * If no charset is provided the default of ISO-8859-1 (Latin 1) will |
| 697 * be used. |
| 698 * |
| 699 * HttpResponse response = ... |
| 700 * response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain"); |
| 701 * response.write(...); // Strings written will be ISO-8859-1 encoded. |
| 702 * |
| 703 * If an unsupported encoding is used an exception will be thrown if |
| 704 * using one of the write methods taking a string. |
679 */ | 705 */ |
680 abstract class HttpResponse implements IOSink<HttpResponse> { | 706 abstract class HttpResponse implements IOSink<HttpResponse> { |
681 // TODO(ajohnsen): Add documentation of how to pipe a file to the response. | 707 // TODO(ajohnsen): Add documentation of how to pipe a file to the response. |
682 /** | 708 /** |
683 * Gets and sets the content length of the response. If the size of | 709 * Gets and sets the content length of the response. If the size of |
684 * the response is not known in advance set the content length to | 710 * the response is not known in advance set the content length to |
685 * -1 - which is also the default if not set. | 711 * -1 - which is also the default if not set. |
686 */ | 712 */ |
687 int contentLength; | 713 int contentLength; |
688 | 714 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 * trying to establish a new connection after calling [shutdown] | 879 * trying to establish a new connection after calling [shutdown] |
854 * will throw an exception. | 880 * will throw an exception. |
855 */ | 881 */ |
856 void close({bool force: false}); | 882 void close({bool force: false}); |
857 } | 883 } |
858 | 884 |
859 | 885 |
860 /** | 886 /** |
861 * HTTP request for a client connection. | 887 * HTTP request for a client connection. |
862 * | 888 * |
863 * The request is an [IOSink], used to write the request data. When | 889 * This object has a number of properties for setting up the HTTP |
864 * all request data has been written, close the stream to indicate the end of | 890 * header of the request. When the header has been set up the methods |
865 * the request. | 891 * from the [IOSink] can be used to write the actual body of the HTTP |
| 892 * request. When one of the [IOSink] methods is used for the first |
| 893 * time the request header is send. Calling any methods that will |
| 894 * change the header after it is sent will throw an exception. |
866 * | 895 * |
867 * When this is accessed for the first time the request header is | 896 * When writing string data through the [IOSink] the |
868 * send. Calling any methods that will change the header after | 897 * encoding used will be determined from the "charset" parameter of |
869 * having retrieved the output stream will throw an exception. | 898 * the "Content-Type" header. |
| 899 * |
| 900 * HttpClientRequest request = ... |
| 901 * request.headers.contentType |
| 902 * = new ContentType("application", "json", charset: "utf-8"); |
| 903 * request.write(...); // Strings written will be UTF-8 encoded. |
| 904 * |
| 905 * If no charset is provided the default of ISO-8859-1 (Latin 1) will |
| 906 * be used. |
| 907 * |
| 908 * HttpClientRequest request = ... |
| 909 * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain"); |
| 910 * request.write(...); // Strings written will be ISO-8859-1 encoded. |
| 911 * |
| 912 * If an unsupported encoding is used an exception will be thrown if |
| 913 * using one of the write methods taking a string. |
870 */ | 914 */ |
871 abstract class HttpClientRequest | 915 abstract class HttpClientRequest |
872 implements IOSink<HttpClientRequest> { | 916 implements IOSink<HttpClientRequest> { |
873 /** | 917 /** |
874 * Gets and sets the content length of the request. If the size of | 918 * Gets and sets the content length of the request. If the size of |
875 * the request is not known in advance set content length to -1, | 919 * the request is not known in advance set content length to -1, |
876 * which is also the default. | 920 * which is also the default. |
877 */ | 921 */ |
878 int contentLength; | 922 int contentLength; |
879 | 923 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 class RedirectLimitExceededException extends RedirectException { | 1165 class RedirectLimitExceededException extends RedirectException { |
1122 const RedirectLimitExceededException(List<RedirectInfo> redirects) | 1166 const RedirectLimitExceededException(List<RedirectInfo> redirects) |
1123 : super("Redirect limit exceeded", redirects); | 1167 : super("Redirect limit exceeded", redirects); |
1124 } | 1168 } |
1125 | 1169 |
1126 | 1170 |
1127 class RedirectLoopException extends RedirectException { | 1171 class RedirectLoopException extends RedirectException { |
1128 const RedirectLoopException(List<RedirectInfo> redirects) | 1172 const RedirectLoopException(List<RedirectInfo> redirects) |
1129 : super("Redirect loop detected", redirects); | 1173 : super("Redirect loop detected", redirects); |
1130 } | 1174 } |
OLD | NEW |