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

Side by Side Diff: lib/http.dart

Issue 1243783002: Add a shortcut for PATCH. (Closed) Base URL: git@github.com:dart-lang/http@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/base_client.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) 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 /// A composable, [Future]-based library for making HTTP requests. 5 /// A composable, [Future]-based library for making HTTP requests.
6 library http; 6 library http;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 /// 89 ///
90 /// [encoding] defaults to [UTF8]. 90 /// [encoding] defaults to [UTF8].
91 /// 91 ///
92 /// For more fine-grained control over the request, use [Request] or 92 /// For more fine-grained control over the request, use [Request] or
93 /// [StreamedRequest] instead. 93 /// [StreamedRequest] instead.
94 Future<Response> put(url, {Map<String, String> headers, body, 94 Future<Response> put(url, {Map<String, String> headers, body,
95 Encoding encoding}) => 95 Encoding encoding}) =>
96 _withClient((client) => client.put(url, 96 _withClient((client) => client.put(url,
97 headers: headers, body: body, encoding: encoding)); 97 headers: headers, body: body, encoding: encoding));
98 98
99 /// Sends an HTTP PATCH request with the given headers and body to the given
100 /// URL, which can be a [Uri] or a [String].
101 ///
102 /// [body] sets the body of the request. It can be a [String], a [List<int>] or
103 /// a [Map<String, String>]. If it's a String, it's encoded using [encoding] and
104 /// used as the body of the request. The content-type of the request will
105 /// default to "text/plain".
106 ///
107 /// If [body] is a List, it's used as a list of bytes for the body of the
108 /// request.
109 ///
110 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
111 /// content-type of the request will be set to
112 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
113 ///
114 /// [encoding] defaults to [UTF8].
115 ///
116 /// For more fine-grained control over the request, use [Request] or
117 /// [StreamedRequest] instead.
118 Future<Response> patch(url, {Map<String, String> headers, body,
119 Encoding encoding}) =>
120 _withClient((client) => client.patch(url,
121 headers: headers, body: body, encoding: encoding));
122
99 /// Sends an HTTP DELETE request with the given headers to the given URL, which 123 /// Sends an HTTP DELETE request with the given headers to the given URL, which
100 /// can be a [Uri] or a [String]. 124 /// can be a [Uri] or a [String].
101 /// 125 ///
102 /// This automatically initializes a new [Client] and closes that client once 126 /// This automatically initializes a new [Client] and closes that client once
103 /// the request is complete. If you're planning on making multiple requests to 127 /// the request is complete. If you're planning on making multiple requests to
104 /// the same server, you should use a single [Client] for all of those requests. 128 /// the same server, you should use a single [Client] for all of those requests.
105 /// 129 ///
106 /// For more fine-grained control over the request, use [Request] instead. 130 /// For more fine-grained control over the request, use [Request] instead.
107 Future<Response> delete(url, {Map<String, String> headers}) => 131 Future<Response> delete(url, {Map<String, String> headers}) =>
108 _withClient((client) => client.delete(url, headers: headers)); 132 _withClient((client) => client.delete(url, headers: headers));
(...skipping 28 matching lines...) Expand all
137 /// For more fine-grained control over the request and response, use [Request] 161 /// For more fine-grained control over the request and response, use [Request]
138 /// instead. 162 /// instead.
139 Future<Uint8List> readBytes(url, {Map<String, String> headers}) => 163 Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
140 _withClient((client) => client.readBytes(url, headers: headers)); 164 _withClient((client) => client.readBytes(url, headers: headers));
141 165
142 Future _withClient(Future fn(Client)) { 166 Future _withClient(Future fn(Client)) {
143 var client = new Client(); 167 var client = new Client();
144 var future = fn(client); 168 var future = fn(client);
145 return future.whenComplete(client.close); 169 return future.whenComplete(client.close);
146 } 170 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/base_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698