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

Unified Diff: pkg/http/lib/src/client.dart

Issue 65583004: Add utility methods for sending non-form data in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review Created 7 years, 1 month 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 | « pkg/http/lib/src/base_client.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/lib/src/client.dart
diff --git a/pkg/http/lib/src/client.dart b/pkg/http/lib/src/client.dart
index 27626cc3c0b4dccb4e62f279435305607ff2fd30..1e6771fbfacc1e5dd44ec9b1f2f1e2bd6d06dadb 100644
--- a/pkg/http/lib/src/client.dart
+++ b/pkg/http/lib/src/client.dart
@@ -5,6 +5,7 @@
library client;
import 'dart:async';
+import 'dart:convert';
import 'dart:typed_data';
import 'base_client.dart';
@@ -39,25 +40,47 @@ abstract class Client {
/// For more fine-grained control over the request, use [send] instead.
Future<Response> get(url, {Map<String, String> headers});
- /// Sends an HTTP POST request with the given headers and fields to the given
- /// URL, which can be a [Uri] or a [String]. If any fields are specified, the
- /// content-type is automatically set to
- /// `"application/x-www-form-urlencoded"`.
+ /// Sends an HTTP POST request with the given headers and body to the given
+ /// URL, which can be a [Uri] or a [String].
+ ///
+ /// [body] sets the body of the request. It can be a [String], a [List<int>]
+ /// or a [Map<String, String>]. If it's a String, it's encoded using
+ /// [encoding] and used as the body of the request. The content-type of the
+ /// request will default to "text/plain".
+ ///
+ /// If [body] is a List, it's used as a list of bytes for the body of the
+ /// request.
+ ///
+ /// If [body] is a Map, it's encoded as form fields using [encoding]. The
+ /// content-type of the request will be set to
+ /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
+ ///
+ /// [encoding] defaults to [UTF8].
///
/// For more fine-grained control over the request, use [send] instead.
- Future<Response> post(url,
- {Map<String, String> headers,
- Map<String, String> fields});
+ Future<Response> post(url, {Map<String, String> headers, body,
+ Encoding encoding});
- /// Sends an HTTP PUT request with the given headers and fields to the given
- /// URL, which can be a [Uri] or a [String]. If any fields are specified, the
- /// content-type is automatically set to
- /// `"application/x-www-form-urlencoded"`.
+ /// Sends an HTTP PUT request with the given headers and body to the given
+ /// URL, which can be a [Uri] or a [String].
+ ///
+ /// [body] sets the body of the request. It can be a [String], a [List<int>]
+ /// or a [Map<String, String>]. If it's a String, it's encoded using
+ /// [encoding] and used as the body of the request. The content-type of the
+ /// request will default to "text/plain".
+ ///
+ /// If [body] is a List, it's used as a list of bytes for the body of the
+ /// request.
+ ///
+ /// If [body] is a Map, it's encoded as form fields using [encoding]. The
+ /// content-type of the request will be set to
+ /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
+ ///
+ /// [encoding] defaults to [UTF8].
///
/// For more fine-grained control over the request, use [send] instead.
- Future<Response> put(url,
- {Map<String, String> headers,
- Map<String, String> fields});
+ Future<Response> put(url, {Map<String, String> headers, body,
+ Encoding encoding});
/// Sends an HTTP DELETE request with the given headers to the given URL,
/// which can be a [Uri] or a [String].
« no previous file with comments | « pkg/http/lib/src/base_client.dart ('k') | pkg/http/test/http_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698