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

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: 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
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-is as the body of the request.
52 ///
53 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
54 /// content-type of the request will be set to
55 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
56 ///
57 /// [encoding] defaults to [UTF8].
46 /// 58 ///
47 /// For more fine-grained control over the request, use [send] instead. 59 /// For more fine-grained control over the request, use [send] instead.
48 Future<Response> post(url, 60 Future<Response> post(url, {Map<String, String> headers, body,
49 {Map<String, String> headers, 61 Encoding encoding});
50 Map<String, String> fields});
51 62
52 /// Sends an HTTP PUT request with the given headers and fields to the given 63 /// 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 64 /// URL, which can be a [Uri] or a [String].
54 /// content-type is automatically set to 65 ///
55 /// `"application/x-www-form-urlencoded"`. 66 /// [body] sets the body of the request. It can be a [String], a [List<int>]
67 /// or a [Map<String, String>]. If it's a String, it's encoded using
68 /// [encoding] and used as the body of the request. The content-type of the
69 /// request will default to "text/plain".
70 ///
71 /// If [body] is a List, it's used as-is as the body of the request.
72 ///
73 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
74 /// content-type of the request will be set to
75 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
76 ///
77 /// [encoding] defaults to [UTF8].
56 /// 78 ///
57 /// For more fine-grained control over the request, use [send] instead. 79 /// For more fine-grained control over the request, use [send] instead.
58 Future<Response> put(url, 80 Future<Response> put(url, {Map<String, String> headers, body,
59 {Map<String, String> headers, 81 Encoding encoding});
60 Map<String, String> fields});
61 82
62 /// Sends an HTTP DELETE request with the given headers to the given URL, 83 /// Sends an HTTP DELETE request with the given headers to the given URL,
63 /// which can be a [Uri] or a [String]. 84 /// which can be a [Uri] or a [String].
64 /// 85 ///
65 /// For more fine-grained control over the request, use [send] instead. 86 /// For more fine-grained control over the request, use [send] instead.
66 Future<Response> delete(url, {Map<String, String> headers}); 87 Future<Response> delete(url, {Map<String, String> headers});
67 88
68 /// Sends an HTTP GET request with the given headers to the given URL, which 89 /// 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 90 /// can be a [Uri] or a [String], and returns a Future that completes to the
70 /// body of the response as a String. 91 /// body of the response as a String.
(...skipping 17 matching lines...) Expand all
88 Future<Uint8List> readBytes(url, {Map<String, String> headers}); 109 Future<Uint8List> readBytes(url, {Map<String, String> headers});
89 110
90 /// Sends an HTTP request and asynchronously returns the response. 111 /// Sends an HTTP request and asynchronously returns the response.
91 Future<StreamedResponse> send(BaseRequest request); 112 Future<StreamedResponse> send(BaseRequest request);
92 113
93 /// Closes the client and cleans up any resources associated with it. It's 114 /// 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 115 /// important to close each client when it's done being used; failing to do so
95 /// can cause the Dart process to hang. 116 /// can cause the Dart process to hang.
96 void close(); 117 void close();
97 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698