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

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

Issue 299443013: Add initial version of http_base package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments 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 | « dart/pkg/http_base/README.md ('k') | dart/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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library http_base;
6
7 import 'dart:async';
8
9 /**
10 * Representation of a set of HTTP headers.
11 */
12 abstract class Headers {
13 /**
14 * Returns the names of all header fields.
15 */
16 Iterable<String> get names;
17
18 /**
19 * Returns `true` if a header field of the specified [name] exist.
20 */
21 bool contains(String name);
22
23 /**
24 * Returns the value for the header field named [name].
25 *
26 * The HTTP standard supports multiple values for each header field name.
27 * Header fields with multiple values can be represented as a
28 * comma-separated list. If a header has multiple values the returned string
29 * is the comma-separated list of all these values.
30 *
31 * For header field-names which do not allow combining multiple values with
32 * comma, this index operator will throw `IllegalArgument`.
33 * This is currently the case for the 'Cookie' and 'Set-Cookie' headers. Use
34 * `getMultiple` method to iterate over the header values for these.
35 */
36 String operator [](String name);
37
38 /**
39 * Returns the values for the header field named [name].
40 *
41 * The order in which the values for the field name appear is the same
42 * as the order in which they are to be send or was received.
43 */
44 Iterable<String> getMultiple(String name);
45 }
46
47
48 /**
49 * Representation of a HTTP request.
50 */
51 abstract class Request {
52 /**
53 * Request method.
54 */
55 String get method;
56
57 /**
58 * Request url.
59 */
60 Uri get url;
61
62 /**
63 * Request headers.
64 */
65 Headers get headers;
66
67 /**
68 * Request body.
69 */
70 Stream<List<int>> read();
71 }
72
73
74 /**
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;
87
88 /**
89 * Response body.
90 */
91 Stream<List<int>> read();
92 }
93
94
95
96 /**
97 * Function for performing a HTTP request.
98 *
99 * The [Client] may use any transport mechanism it wants
100 * (e.g. HTTP/1.1, HTTP/2.0, SPDY) to perform the HTTP request.
101 *
102 * [Client]s are composable. E.g. A [Client] may add an 'Authorization'
103 * header to [request] and forward to another [Client].
104 *
105 * A [Client] may ignore connection specific headers in [request] and may
106 * not present them in the [Response] object.
107 *
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 | « dart/pkg/http_base/README.md ('k') | dart/pkg/http_base/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698