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

Side by Side Diff: pkg/http/lib/src/client.dart

Issue 261763002: Rip out the last dart:io dependency from pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | pkg/http/lib/src/io.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:convert';
9 import 'dart:typed_data'; 9 import 'dart:typed_data';
10 10
11 import 'base_client.dart'; 11 import 'base_client.dart';
12 import 'base_request.dart'; 12 import 'base_request.dart';
13 import 'io.dart' as io;
13 import 'io_client.dart'; 14 import 'io_client.dart';
15 import 'response.dart';
14 import 'streamed_response.dart'; 16 import 'streamed_response.dart';
15 import 'response.dart';
16 17
17 /// The interface for HTTP clients that take care of maintaining persistent 18 /// The interface for HTTP clients that take care of maintaining persistent
18 /// connections across multiple requests to the same server. If you only need to 19 /// connections across multiple requests to the same server. If you only need to
19 /// send a single request, it's usually easier to use [head], [get], [post], 20 /// send a single request, it's usually easier to use [head], [get], [post],
20 /// [put], or [delete] instead. 21 /// [put], or [delete] instead.
21 /// 22 ///
22 /// When creating an HTTP client class with additional functionality, you must 23 /// When creating an HTTP client class with additional functionality, you must
23 /// extend [BaseClient] rather than [Client]. In most cases, you can wrap 24 /// extend [BaseClient] rather than [Client]. In most cases, you can wrap
24 /// another instance of [Client] and add functionality on top of that. This 25 /// another instance of [Client] and add functionality on top of that. This
25 /// allows all classes implementing [Client] to be mutually composable. 26 /// allows all classes implementing [Client] to be mutually composable.
26 abstract class Client { 27 abstract class Client {
27 /// Creates a new Client using the default implementation. This implementation 28 /// Creates a new client.
28 /// uses an underlying `dart:io` [HttpClient] to make requests. 29 ///
29 factory Client() => new IOClient(); 30 /// Currently this will create an [IOClient] if `dart:io` is available and
31 /// throw an [UnsupportedError] otherwise. In the future, it will create a
32 /// [BrowserClient] if `dart:html` is available.
33 factory Client() {
34 io.assertSupported("IOClient");
35 return new IOClient();
36 }
30 37
31 /// Sends an HTTP HEAD request with the given headers to the given URL, which 38 /// Sends an HTTP HEAD request with the given headers to the given URL, which
32 /// can be a [Uri] or a [String]. 39 /// can be a [Uri] or a [String].
33 /// 40 ///
34 /// For more fine-grained control over the request, use [send] instead. 41 /// For more fine-grained control over the request, use [send] instead.
35 Future<Response> head(url, {Map<String, String> headers}); 42 Future<Response> head(url, {Map<String, String> headers});
36 43
37 /// Sends an HTTP GET request with the given headers to the given URL, which 44 /// Sends an HTTP GET request with the given headers to the given URL, which
38 /// can be a [Uri] or a [String]. 45 /// can be a [Uri] or a [String].
39 /// 46 ///
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Future<Uint8List> readBytes(url, {Map<String, String> headers}); 118 Future<Uint8List> readBytes(url, {Map<String, String> headers});
112 119
113 /// Sends an HTTP request and asynchronously returns the response. 120 /// Sends an HTTP request and asynchronously returns the response.
114 Future<StreamedResponse> send(BaseRequest request); 121 Future<StreamedResponse> send(BaseRequest request);
115 122
116 /// Closes the client and cleans up any resources associated with it. It's 123 /// Closes the client and cleans up any resources associated with it. It's
117 /// important to close each client when it's done being used; failing to do so 124 /// important to close each client when it's done being used; failing to do so
118 /// can cause the Dart process to hang. 125 /// can cause the Dart process to hang.
119 void close(); 126 void close();
120 } 127 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | pkg/http/lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698