Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: sdk/lib/io/http.dart

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http.dart
diff --git a/sdk/lib/io/http.dart b/sdk/lib/io/http.dart
index 2eddf7ca202419f8c5f59e15e6832a2123389257..912a366d737af66da4a3bdca182ba71b277fcba2 100644
--- a/sdk/lib/io/http.dart
+++ b/sdk/lib/io/http.dart
@@ -676,6 +676,32 @@ abstract class HttpRequest implements Stream<List<int>> {
/**
* HTTP response to be send back to the client.
+ *
+ * This object has a number of properties for setting up the HTTP
+ * header of the response. When the header has been set up the methods
+ * from the [IOSink] can be used to write the actual body of the HTTP
+ * response. When one of the [IOSink] methods is used for the
+ * first time the request header is send. Calling any methods that
+ * will change the header after it is sent will throw an exception.
+ *
+ * When writing string data through the [IOSink] the encoding used
+ * will be determined from the "charset" parameter of the
+ * "Content-Type" header.
+ *
+ * HttpResponse response = ...
+ * response.headers.contentType
+ * = new ContentType("application", "json", charset: "utf-8");
+ * response.write(...); // Strings written will be UTF-8 encoded.
+ *
+ * If no charset is provided the default of ISO-8859-1 (Latin 1) will
+ * be used.
+ *
+ * HttpResponse response = ...
+ * response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
+ * response.write(...); // Strings written will be ISO-8859-1 encoded.
+ *
+ * If an unsupported encoding is used an exception will be thrown if
+ * using one of the write methods taking a string.
*/
abstract class HttpResponse implements IOSink<HttpResponse> {
// TODO(ajohnsen): Add documentation of how to pipe a file to the response.
@@ -860,13 +886,31 @@ abstract class HttpClient {
/**
* HTTP request for a client connection.
*
- * The request is an [IOSink], used to write the request data. When
- * all request data has been written, close the stream to indicate the end of
- * the request.
+ * This object has a number of properties for setting up the HTTP
+ * header of the request. When the header has been set up the methods
+ * from the [IOSink] can be used to write the actual body of the HTTP
+ * request. When one of the [IOSink] methods is used for the first
+ * time the request header is send. Calling any methods that will
+ * change the header after it is sent will throw an exception.
+ *
+ * When writing string data through the [IOSink] the
+ * encoding used will be determined from the "charset" parameter of
+ * the "Content-Type" header.
+ *
+ * HttpClientRequest request = ...
+ * request.headers.contentType
+ * = new ContentType("application", "json", charset: "utf-8");
+ * request.write(...); // Strings written will be UTF-8 encoded.
+ *
+ * If no charset is provided the default of ISO-8859-1 (Latin 1) will
+ * be used.
+ *
+ * HttpClientRequest request = ...
+ * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
+ * request.write(...); // Strings written will be ISO-8859-1 encoded.
*
- * When this is accessed for the first time the request header is
- * send. Calling any methods that will change the header after
- * having retrieved the output stream will throw an exception.
+ * If an unsupported encoding is used an exception will be thrown if
+ * using one of the write methods taking a string.
*/
abstract class HttpClientRequest
implements IOSink<HttpClientRequest> {
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698