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

Side by Side Diff: pkg/http_base/lib/http_base.dart

Issue 297163004: pkg/http_base: starting alignment with http and shelf (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 6 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_base/CHANGELOG.md ('k') | pkg/http_base/pubspec.yaml » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 http_base; 5 library http_base;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 /** 9 /// Representation of a set of HTTP headers.
10 * Representation of a set of HTTP headers.
11 */
12 abstract class Headers { 10 abstract class Headers {
13 /** 11 /// Returns the names of all header fields.
14 * Returns the names of all header fields.
15 */
16 Iterable<String> get names; 12 Iterable<String> get names;
17 13
18 /** 14 /// Returns `true` if a header field of the specified [name] exist.
19 * Returns `true` if a header field of the specified [name] exist.
20 */
21 bool contains(String name); 15 bool contains(String name);
22 16
23 /** 17 /// Returns the value for the header field named [name].
24 * Returns the value for the header field named [name]. 18 ///
25 * 19 /// The HTTP standard supports multiple values for each header field name.
26 * The HTTP standard supports multiple values for each header field name. 20 /// Header fields with multiple values can be represented as a
27 * Header fields with multiple values can be represented as a 21 /// comma-separated list. If a header has multiple values the returned string
28 * comma-separated list. If a header has multiple values the returned string 22 /// is the comma-separated list of all these values.
29 * is the comma-separated list of all these values. 23 ///
30 * 24 /// For header field-names which do not allow combining multiple values with
31 * For header field-names which do not allow combining multiple values with 25 /// comma, this index operator will throw `IllegalArgument`.
32 * comma, this index operator will throw `IllegalArgument`. 26 /// This is currently the case for the 'Cookie' and 'Set-Cookie' headers. Use
33 * This is currently the case for the 'Cookie' and 'Set-Cookie' headers. Use 27 /// `getMultiple` method to iterate over the header values for these.
34 * `getMultiple` method to iterate over the header values for these.
35 */
36 String operator [](String name); 28 String operator [](String name);
37 29
38 /** 30 /// Returns the values for the header field named [name].
39 * Returns the values for the header field named [name]. 31 ///
40 * 32 /// The order in which the values for the field name appear is the same
41 * The order in which the values for the field name appear is the same 33 /// as the order in which they are to be send or was received.
42 * as the order in which they are to be send or was received.
43 */
44 Iterable<String> getMultiple(String name); 34 Iterable<String> getMultiple(String name);
45 } 35 }
46 36
47 37 /// Representation of a HTTP request.
48 /**
49 * Representation of a HTTP request.
50 */
51 abstract class Request { 38 abstract class Request {
52 /** 39 /// Request method.
53 * Request method.
54 */
55 String get method; 40 String get method;
56 41
57 /** 42 /// Request url.
58 * Request url.
59 */
60 Uri get url; 43 Uri get url;
61 44
62 /** 45 /// Request headers.
63 * Request headers.
64 */
65 Headers get headers; 46 Headers get headers;
66 47
67 /** 48 /// Request body.
68 * Request body.
69 */
70 Stream<List<int>> read(); 49 Stream<List<int>> read();
71 } 50 }
72 51
52 /// Representation of a HTTP response.
53 abstract class Response {
54 /// Response status code.
55 int get statusCode;
73 56
74 /** 57 /// Response headers.
75 * Representation of a HTTP response.
76 */
77 abstract class Response {
78 /**
79 * Response status code.
80 */
81 int get status;
82
83 /**
84 * Response headers.
85 */
86 Headers get headers; 58 Headers get headers;
87 59
88 /** 60 /// Response body.
89 * Response body.
90 */
91 Stream<List<int>> read(); 61 Stream<List<int>> read();
92 } 62 }
93 63
94 64 /// Function for performing an HTTP request.
95 65 ///
96 /** 66 /// The [RequestHandler] may use any transport mechanism it wants
97 * Function for performing a HTTP request. 67 /// (e.g. HTTP/1.1, HTTP/2.0, SPDY) to perform the HTTP request.
98 * 68 ///
99 * The [Client] may use any transport mechanism it wants 69 /// [RequestHandler]s are composable. E.g. A [RequestHandler] may add an
100 * (e.g. HTTP/1.1, HTTP/2.0, SPDY) to perform the HTTP request. 70 /// 'Authorization' header to [request] and forward to another [RequestHandler].
101 * 71 ///
102 * [Client]s are composable. E.g. A [Client] may add an 'Authorization' 72 /// A [RequestHandler] may ignore connection specific headers in [request] and
103 * header to [request] and forward to another [Client]. 73 /// may not present them in the [Response] object.
104 * 74 ///
105 * A [Client] may ignore connection specific headers in [request] and may 75 /// Connection specific headers:
106 * not present them in the [Response] object. 76 /// 'Connection', 'Upgrade', 'Keep-Alive', 'Transfer-Encoding'
107 * 77 typedef Future<Response> RequestHandler(Request request);
108 * Connection specific headers:
109 * 'Connection', 'Upgrade', 'Keep-Alive', 'Transfer-Encoding'
110 */
111 typedef Future<Response> Client(Request request);
112
113 /**
114 * Function for handling a HTTP request.
115 *
116 * The [RequestHandler] should not react on any connection specific headers
117 * in [request] and connection specific headers in it's [Response] may be
118 * ignored by a HTTP Server.
119 *
120 * [RequestHandler]s are composable. E.g. A [RequestHandler] may call another
121 * [RequestHandler] and augment the headers with e.g. a 'Set-Cookie' header.
122 *
123 * Connection specific headers:
124 * 'Connection', 'Upgrade', 'Keep-Alive', 'Transfer-Encoding'
125 */
126 typedef Future<Response> HttpRequestHandler(Request request);
OLDNEW
« no previous file with comments | « pkg/http_base/CHANGELOG.md ('k') | pkg/http_base/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698