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

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

Issue 810223002: Remove the http package from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library client;
6
7 import 'dart:async';
8 import 'dart:convert';
9 import 'dart:typed_data';
10
11 import 'base_client.dart';
12 import 'base_request.dart';
13 import 'io.dart' as io;
14 import 'io_client.dart';
15 import 'response.dart';
16 import 'streamed_response.dart';
17
18 /// The interface for HTTP clients that take care of maintaining persistent
19 /// connections across multiple requests to the same server. If you only need to
20 /// send a single request, it's usually easier to use [head], [get], [post],
21 /// [put], or [delete] instead.
22 ///
23 /// When creating an HTTP client class with additional functionality, you must
24 /// extend [BaseClient] rather than [Client]. In most cases, you can wrap
25 /// another instance of [Client] and add functionality on top of that. This
26 /// allows all classes implementing [Client] to be mutually composable.
27 abstract class Client {
28 /// Creates a new client.
29 ///
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 }
37
38 /// Sends an HTTP HEAD request with the given headers to the given URL, which
39 /// can be a [Uri] or a [String].
40 ///
41 /// For more fine-grained control over the request, use [send] instead.
42 Future<Response> head(url, {Map<String, String> headers});
43
44 /// Sends an HTTP GET request with the given headers to the given URL, which
45 /// can be a [Uri] or a [String].
46 ///
47 /// For more fine-grained control over the request, use [send] instead.
48 Future<Response> get(url, {Map<String, String> headers});
49
50 /// Sends an HTTP POST request with the given headers and body to the given
51 /// URL, which can be a [Uri] or a [String].
52 ///
53 /// [body] sets the body of the request. It can be a [String], a [List<int>]
54 /// or a [Map<String, String>]. If it's a String, it's encoded using
55 /// [encoding] and used as the body of the request. The content-type of the
56 /// request will default to "text/plain".
57 ///
58 /// If [body] is a List, it's used as a list of bytes for the body of the
59 /// request.
60 ///
61 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
62 /// content-type of the request will be set to
63 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
64 ///
65 /// [encoding] defaults to [UTF8].
66 ///
67 /// For more fine-grained control over the request, use [send] instead.
68 Future<Response> post(url, {Map<String, String> headers, body,
69 Encoding encoding});
70
71 /// Sends an HTTP PUT request with the given headers and body to the given
72 /// URL, which can be a [Uri] or a [String].
73 ///
74 /// [body] sets the body of the request. It can be a [String], a [List<int>]
75 /// or a [Map<String, String>]. If it's a String, it's encoded using
76 /// [encoding] and used as the body of the request. The content-type of the
77 /// request will default to "text/plain".
78 ///
79 /// If [body] is a List, it's used as a list of bytes for the body of the
80 /// request.
81 ///
82 /// If [body] is a Map, it's encoded as form fields using [encoding]. The
83 /// content-type of the request will be set to
84 /// `"application/x-www-form-urlencoded"`; this cannot be overridden.
85 ///
86 /// [encoding] defaults to [UTF8].
87 ///
88 /// For more fine-grained control over the request, use [send] instead.
89 Future<Response> put(url, {Map<String, String> headers, body,
90 Encoding encoding});
91
92 /// Sends an HTTP DELETE request with the given headers to the given URL,
93 /// which can be a [Uri] or a [String].
94 ///
95 /// For more fine-grained control over the request, use [send] instead.
96 Future<Response> delete(url, {Map<String, String> headers});
97
98 /// Sends an HTTP GET request with the given headers to the given URL, which
99 /// can be a [Uri] or a [String], and returns a Future that completes to the
100 /// body of the response as a String.
101 ///
102 /// The Future will emit a [ClientException] if the response doesn't have a
103 /// success status code.
104 ///
105 /// For more fine-grained control over the request and response, use [send] or
106 /// [get] instead.
107 Future<String> read(url, {Map<String, String> headers});
108
109 /// Sends an HTTP GET request with the given headers to the given URL, which
110 /// can be a [Uri] or a [String], and returns a Future that completes to the
111 /// body of the response as a list of bytes.
112 ///
113 /// The Future will emit a [ClientException] if the response doesn't have a
114 /// success status code.
115 ///
116 /// For more fine-grained control over the request and response, use [send] or
117 /// [get] instead.
118 Future<Uint8List> readBytes(url, {Map<String, String> headers});
119
120 /// Sends an HTTP request and asynchronously returns the response.
121 Future<StreamedResponse> send(BaseRequest request);
122
123 /// Closes the client and cleans up any resources associated with it. It's
124 /// important to close each client when it's done being used; failing to do so
125 /// can cause the Dart process to hang.
126 void close();
127 }
OLDNEW
« no previous file with comments | « pkg/http/lib/src/byte_stream.dart ('k') | pkg/http/lib/src/exception.dart » ('j') | pkg/pkg.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698