Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 /** | |
|
kevmoo
2014/05/23 21:22:24
All packages are moving towards triple-slash "///"
Søren Gjesse
2014/05/26 07:12:46
In my opinion the "///" doc comments are harder to
kustermann
2014/05/26 09:12:31
If you say "All packages are moving towards triple
| |
| 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. | |
|
kevmoo
2014/05/23 21:22:24
`true`
kustermann
2014/05/26 09:12:31
Done.
| |
| 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 the 'Cookie' and 'Set-Cookie' headers the comma-separated list | |
|
kevmoo
2014/05/23 21:22:24
We should not specify an undefined behavior for a
Søren Gjesse
2014/05/26 07:12:46
If we should specify something here lets go for th
kustermann
2014/05/26 09:12:31
Done.
| |
| 32 * representation does not work, and for these headers using this method is | |
| 33 * undefined. Use the `getMultiple` method for these headers. | |
| 34 */ | |
| 35 String operator [](String name); | |
| 36 | |
| 37 /** | |
| 38 * Returns the values for the header field named [name]. | |
| 39 * | |
| 40 * The order in which the values for the field name appear is the same | |
| 41 * as the order in which they are to be send or was received. | |
| 42 */ | |
| 43 Iterable<String> getMultiple(String name); | |
| 44 } | |
| 45 | |
| 46 | |
| 47 /** | |
| 48 * Representation of a HTTP request. | |
| 49 */ | |
| 50 abstract class Request { | |
| 51 /** | |
| 52 * Request method. | |
| 53 */ | |
| 54 String get method; | |
| 55 | |
| 56 /** | |
| 57 * Request url. | |
| 58 */ | |
| 59 Uri get url; | |
| 60 | |
| 61 /** | |
| 62 * Request headers. | |
| 63 */ | |
| 64 Headers get headers; | |
| 65 | |
| 66 /** | |
| 67 * Request body. | |
| 68 */ | |
| 69 Stream<List<int>> get body; | |
|
kevmoo
2014/05/23 21:22:24
Use a method here: read()
In many cases, the body
kustermann
2014/05/26 09:12:31
Done.
kustermann
2014/05/26 09:12:31
Done.
| |
| 70 } | |
| 71 | |
| 72 | |
| 73 /** | |
| 74 * Representation of a HTTP response. | |
| 75 */ | |
| 76 abstract class Response { | |
| 77 /** | |
| 78 * Response status code. | |
| 79 */ | |
| 80 int get statusCode; | |
|
Søren Gjesse
2014/05/26 07:12:46
If we remove reasonPhrase lets change this to just
kustermann
2014/05/26 09:12:31
Done.
kustermann
2014/05/26 09:12:31
Done.
| |
| 81 | |
| 82 /** | |
| 83 * Response reason phrase. | |
| 84 */ | |
| 85 String get reasonPhrase; | |
|
kevmoo
2014/05/23 21:22:24
Can we skip this?
It's not supported in HTTP 2.0
Søren Gjesse
2014/05/26 07:12:46
I am OK with that - I does not add much value.
Th
kustermann
2014/05/26 09:12:31
Removed.
| |
| 86 | |
| 87 /** | |
| 88 * Response headers. | |
| 89 */ | |
| 90 Headers get headers; | |
| 91 | |
| 92 /** | |
| 93 * Response body. | |
| 94 */ | |
| 95 Stream<List<int>> get body; | |
|
kevmoo
2014/05/23 21:22:24
read() here, too. Same as above.
kustermann
2014/05/26 09:12:31
Done.
| |
| 96 } | |
| 97 | |
| 98 | |
| 99 | |
| 100 /** | |
| 101 * Function for performing an http request. | |
|
Søren Gjesse
2014/05/23 12:25:30
http -> HTTP
Here is says 'an HTTP', and other pl
kustermann
2014/05/26 09:12:31
Done.
| |
| 102 * | |
| 103 * The [HttpClient] may use any transport mechanism it wants | |
| 104 * (e.g. HTTP/1.1, HTTP/2.0, SPDY) to perform the http request. | |
| 105 * | |
| 106 * [HttpClient]s are composable. E.g. A [HttpClient] may add an | |
| 107 * 'Authorization' header to [request] and forward to another [HttpClient]. | |
| 108 * | |
| 109 * A [HttpClient] handler may ignore connection specific headers in [request] | |
| 110 * and may not present them in the [Response] object. | |
| 111 * | |
| 112 * Connection specific headers: | |
| 113 * 'Connection', 'Upgrade', 'Keep-Alive', 'Transfer-Encoding' | |
| 114 * | |
| 115 */ | |
| 116 typedef Future<Response> HttpClient(Request request); | |
|
kevmoo
2014/05/23 21:22:24
We must not export two identical typedefs. Not wor
kevmoo
2014/05/23 21:22:24
There is already an HttpClient in dart:io. We DON'
kevmoo
2014/05/23 22:07:05
Requester?
Søren Gjesse
2014/05/26 07:12:46
I agree that this can be confusing. However the "c
kustermann
2014/05/26 09:12:31
Removed the prefix, users should use prefix import
| |
| 117 | |
| 118 /** | |
| 119 * Function for handling an http request. | |
|
Søren Gjesse
2014/05/23 12:25:30
http -> HTTP
kustermann
2014/05/26 09:12:31
Done.
kustermann
2014/05/26 09:12:31
Done.
| |
| 120 * | |
| 121 * The [HttpRequestHandler] should not react on any connection specific headers | |
| 122 * in [request] and connection specific headers in it's [Response] may be | |
| 123 * ignored by an Http Server. | |
|
Søren Gjesse
2014/05/23 12:25:30
Http -> HTTP
kustermann
2014/05/26 09:12:31
Done.
kustermann
2014/05/26 09:12:31
Done.
| |
| 124 * | |
| 125 * [HttpRequestHandler]s are composable. E.g. A [HttpRequestHandler] may call | |
| 126 * another [HttpRequestHandler] and augment the headers with a 'Set-Cookie' | |
|
Søren Gjesse
2014/05/23 12:25:30
with -> with e.g.
kustermann
2014/05/26 09:12:31
Done.
kustermann
2014/05/26 09:12:31
Done.
| |
| 127 * header. | |
| 128 * | |
| 129 * Connection specific headers: | |
| 130 * 'Connection', 'Upgrade', 'Keep-Alive', 'Transfer-Encoding' | |
| 131 */ | |
| 132 typedef Future<Response> HttpRequestHandler(Request request); | |
|
kevmoo
2014/05/23 22:07:05
Eliminate this typedef. We only have confusion if
kustermann
2014/05/26 09:12:31
Not done. See above.
| |
| OLD | NEW |