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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library client; 5 library client;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert';
8 import 'dart:typed_data'; 9 import 'dart:typed_data';
9 10
10 import 'base_client.dart'; 11 import 'base_client.dart';
11 import 'base_request.dart'; 12 import 'base_request.dart';
12 import 'io_client.dart'; 13 import 'io_client.dart';
13 import 'streamed_response.dart'; 14 import 'streamed_response.dart';
14 import 'response.dart'; 15 import 'response.dart';
15 16
16 /// The interface for HTTP clients that take care of maintaining persistent 17 /// The interface for HTTP clients that take care of maintaining persistent
17 /// connections across multiple requests to the same server. If you only need to 18 /// connections across multiple requests to the same server. If you only need to
(...skipping 14 matching lines...) Expand all
32 /// 33 ///
33 /// For more fine-grained control over the request, use [send] instead. 34 /// For more fine-grained control over the request, use [send] instead.
34 Future<Response> head(url, {Map<String, String> headers}); 35 Future<Response> head(url, {Map<String, String> headers});
35 36
36 /// Sends an HTTP GET request with the given headers to the given URL, which 37 /// Sends an HTTP GET request with the given headers to the given URL, which
37 /// can be a [Uri] or a [String]. 38 /// can be a [Uri] or a [String].
38 /// 39 ///
39 /// For more fine-grained control over the request, use [send] instead. 40 /// For more fine-grained control over the request, use [send] instead.
40 Future<Response> get(url, {Map<String, String> headers}); 41 Future<Response> get(url, {Map<String, String> headers});
41 42
42 /// Sends an HTTP POST request with the given headers and fields to the given 43 /// Sends an HTTP POST request with the given headers and body to the given
43 /// URL, which can be a [Uri] or a [String]. If any fields are specified, the 44 /// URL, which can be a [Uri] or a [String].
44 /// content-type is automatically set to 45 ///
45 /// `"application/x-www-form-urlencoded"`. 46 /// [body] sets the body of the request. It can be a [String], a [List<int>]
47 /// or a [Map<String, String>]. If it's a String, it's encoded using
48 /// [encoding] and used as the body of the request. The content-type of the
49 /// request will default to "text/plain".
50 ///
51 /// If [body] is a List, it's used as a list of bytes for the body of the
52 /// request.
53 ///
54 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
55 /// content-type of the request will be set to
56 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
57 ///
58 /// [encoding] defaults to [UTF8].
46 /// 59 ///
47 /// For more fine-grained control over the request, use [send] instead. 60 /// For more fine-grained control over the request, use [send] instead.
48 Future<Response> post(url, 61 Future<Response> post(url, {Map<String, String> headers, body,
49 {Map<String, String> headers, 62 Encoding encoding});
50 Map<String, String> fields});
51 63
52 /// Sends an HTTP PUT request with the given headers and fields to the given 64 /// Sends an HTTP PUT request with the given headers and body to the given
53 /// URL, which can be a [Uri] or a [String]. If any fields are specified, the 65 /// URL, which can be a [Uri] or a [String].
54 /// content-type is automatically set to 66 ///
55 /// `"application/x-www-form-urlencoded"`. 67 /// [body] sets the body of the request. It can be a [String], a [List<int>]
68 /// or a [Map<String, String>]. If it's a String, it's encoded using
69 /// [encoding] and used as the body of the request. The content-type of the
70 /// request will default to "text/plain".
71 ///
72 /// If [body] is a List, it's used as a list of bytes for the body of the
73 /// request.
74 ///
75 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
76 /// content-type of the request will be set to
77 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
78 ///
79 /// [encoding] defaults to [UTF8].
56 /// 80 ///
57 /// For more fine-grained control over the request, use [send] instead. 81 /// For more fine-grained control over the request, use [send] instead.
58 Future<Response> put(url, 82 Future<Response> put(url, {Map<String, String> headers, body,
59 {Map<String, String> headers, 83 Encoding encoding});
60 Map<String, String> fields});
61 84
62 /// Sends an HTTP DELETE request with the given headers to the given URL, 85 /// Sends an HTTP DELETE request with the given headers to the given URL,
63 /// which can be a [Uri] or a [String]. 86 /// which can be a [Uri] or a [String].
64 /// 87 ///
65 /// For more fine-grained control over the request, use [send] instead. 88 /// For more fine-grained control over the request, use [send] instead.
66 Future<Response> delete(url, {Map<String, String> headers}); 89 Future<Response> delete(url, {Map<String, String> headers});
67 90
68 /// Sends an HTTP GET request with the given headers to the given URL, which 91 /// Sends an HTTP GET request with the given headers to the given URL, which
69 /// can be a [Uri] or a [String], and returns a Future that completes to the 92 /// can be a [Uri] or a [String], and returns a Future that completes to the
70 /// body of the response as a String. 93 /// body of the response as a String.
(...skipping 17 matching lines...) Expand all
88 Future<Uint8List> readBytes(url, {Map<String, String> headers}); 111 Future<Uint8List> readBytes(url, {Map<String, String> headers});
89 112
90 /// Sends an HTTP request and asynchronously returns the response. 113 /// Sends an HTTP request and asynchronously returns the response.
91 Future<StreamedResponse> send(BaseRequest request); 114 Future<StreamedResponse> send(BaseRequest request);
92 115
93 /// Closes the client and cleans up any resources associated with it. It's 116 /// Closes the client and cleans up any resources associated with it. It's
94 /// important to close each client when it's done being used; failing to do so 117 /// important to close each client when it's done being used; failing to do so
95 /// can cause the Dart process to hang. 118 /// can cause the Dart process to hang.
96 void close(); 119 void close();
97 } 120 }
OLDNEW
« 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