| OLD | NEW |
| 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 /** | 5 /** |
| 6 * HTTP status codes. | 6 * HTTP status codes. |
| 7 */ | 7 */ |
| 8 interface HttpStatus { | 8 interface HttpStatus { |
| 9 static final int CONTINUE = 100; | 9 static const int CONTINUE = 100; |
| 10 static final int SWITCHING_PROTOCOLS = 101; | 10 static const int SWITCHING_PROTOCOLS = 101; |
| 11 static final int OK = 200; | 11 static const int OK = 200; |
| 12 static final int CREATED = 201; | 12 static const int CREATED = 201; |
| 13 static final int ACCEPTED = 202; | 13 static const int ACCEPTED = 202; |
| 14 static final int NON_AUTHORITATIVE_INFORMATION = 203; | 14 static const int NON_AUTHORITATIVE_INFORMATION = 203; |
| 15 static final int NO_CONTENT = 204; | 15 static const int NO_CONTENT = 204; |
| 16 static final int RESET_CONTENT = 205; | 16 static const int RESET_CONTENT = 205; |
| 17 static final int PARTIAL_CONTENT = 206; | 17 static const int PARTIAL_CONTENT = 206; |
| 18 static final int MULTIPLE_CHOICES = 300; | 18 static const int MULTIPLE_CHOICES = 300; |
| 19 static final int MOVED_PERMANENTLY = 301; | 19 static const int MOVED_PERMANENTLY = 301; |
| 20 static final int FOUND = 302; | 20 static const int FOUND = 302; |
| 21 static final int MOVED_TEMPORARILY = 302; // Common alias for FOUND. | 21 static const int MOVED_TEMPORARILY = 302; // Common alias for FOUND. |
| 22 static final int SEE_OTHER = 303; | 22 static const int SEE_OTHER = 303; |
| 23 static final int NOT_MODIFIED = 304; | 23 static const int NOT_MODIFIED = 304; |
| 24 static final int USE_PROXY = 305; | 24 static const int USE_PROXY = 305; |
| 25 static final int TEMPORARY_REDIRECT = 307; | 25 static const int TEMPORARY_REDIRECT = 307; |
| 26 static final int BAD_REQUEST = 400; | 26 static const int BAD_REQUEST = 400; |
| 27 static final int UNAUTHORIZED = 401; | 27 static const int UNAUTHORIZED = 401; |
| 28 static final int PAYMENT_REQUIRED = 402; | 28 static const int PAYMENT_REQUIRED = 402; |
| 29 static final int FORBIDDEN = 403; | 29 static const int FORBIDDEN = 403; |
| 30 static final int NOT_FOUND = 404; | 30 static const int NOT_FOUND = 404; |
| 31 static final int METHOD_NOT_ALLOWED = 405; | 31 static const int METHOD_NOT_ALLOWED = 405; |
| 32 static final int NOT_ACCEPTABLE = 406; | 32 static const int NOT_ACCEPTABLE = 406; |
| 33 static final int PROXY_AUTHENTICATION_REQUIRED = 407; | 33 static const int PROXY_AUTHENTICATION_REQUIRED = 407; |
| 34 static final int REQUEST_TIMEOUT = 408; | 34 static const int REQUEST_TIMEOUT = 408; |
| 35 static final int CONFLICT = 409; | 35 static const int CONFLICT = 409; |
| 36 static final int GONE = 410; | 36 static const int GONE = 410; |
| 37 static final int LENGTH_REQUIRED = 411; | 37 static const int LENGTH_REQUIRED = 411; |
| 38 static final int PRECONDITION_FAILED = 412; | 38 static const int PRECONDITION_FAILED = 412; |
| 39 static final int REQUEST_ENTITY_TOO_LARGE = 413; | 39 static const int REQUEST_ENTITY_TOO_LARGE = 413; |
| 40 static final int REQUEST_URI_TOO_LONG = 414; | 40 static const int REQUEST_URI_TOO_LONG = 414; |
| 41 static final int UNSUPPORTED_MEDIA_TYPE = 415; | 41 static const int UNSUPPORTED_MEDIA_TYPE = 415; |
| 42 static final int REQUESTED_RANGE_NOT_SATISFIABLE = 416; | 42 static const int REQUESTED_RANGE_NOT_SATISFIABLE = 416; |
| 43 static final int EXPECTATION_FAILED = 417; | 43 static const int EXPECTATION_FAILED = 417; |
| 44 static final int INTERNAL_SERVER_ERROR = 500; | 44 static const int INTERNAL_SERVER_ERROR = 500; |
| 45 static final int NOT_IMPLEMENTED = 501; | 45 static const int NOT_IMPLEMENTED = 501; |
| 46 static final int BAD_GATEWAY = 502; | 46 static const int BAD_GATEWAY = 502; |
| 47 static final int SERVICE_UNAVAILABLE = 503; | 47 static const int SERVICE_UNAVAILABLE = 503; |
| 48 static final int GATEWAY_TIMEOUT = 504; | 48 static const int GATEWAY_TIMEOUT = 504; |
| 49 static final int HTTP_VERSION_NOT_SUPPORTED = 505; | 49 static const int HTTP_VERSION_NOT_SUPPORTED = 505; |
| 50 // Client generated status code. | 50 // Client generated status code. |
| 51 static final int NETWORK_CONNECT_TIMEOUT_ERROR = 599; | 51 static const int NETWORK_CONNECT_TIMEOUT_ERROR = 599; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * HTTP server. | 56 * HTTP server. |
| 57 */ | 57 */ |
| 58 interface HttpServer default _HttpServer { | 58 interface HttpServer default _HttpServer { |
| 59 HttpServer(); | 59 HttpServer(); |
| 60 | 60 |
| 61 /** | 61 /** |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * Access to the HTTP headers for requests and responses. In some | 118 * Access to the HTTP headers for requests and responses. In some |
| 119 * situations the headers will be imutable and the mutating methods | 119 * situations the headers will be imutable and the mutating methods |
| 120 * will then throw exceptions. | 120 * will then throw exceptions. |
| 121 * | 121 * |
| 122 * For all operation on HTTP headers the header name is | 122 * For all operation on HTTP headers the header name is |
| 123 * case-insensitive. | 123 * case-insensitive. |
| 124 */ | 124 */ |
| 125 interface HttpHeaders default _HttpHeaders { | 125 interface HttpHeaders default _HttpHeaders { |
| 126 static final ACCEPT = "Accept"; | 126 static const ACCEPT = "Accept"; |
| 127 static final ACCEPT_CHARSET = "Accept-Charset"; | 127 static const ACCEPT_CHARSET = "Accept-Charset"; |
| 128 static final ACCEPT_ENCODING = "Accept-Encoding"; | 128 static const ACCEPT_ENCODING = "Accept-Encoding"; |
| 129 static final ACCEPT_LANGUAGE = "Accept-Language"; | 129 static const ACCEPT_LANGUAGE = "Accept-Language"; |
| 130 static final ACCEPT_RANGES = "Accept-Ranges"; | 130 static const ACCEPT_RANGES = "Accept-Ranges"; |
| 131 static final AGE = "Age"; | 131 static const AGE = "Age"; |
| 132 static final ALLOW = "Allow"; | 132 static const ALLOW = "Allow"; |
| 133 static final AUTHORIZATION = "Authorization"; | 133 static const AUTHORIZATION = "Authorization"; |
| 134 static final CACHE_CONTROL = "Cache-Control"; | 134 static const CACHE_CONTROL = "Cache-Control"; |
| 135 static final CONNECTION = "Connection"; | 135 static const CONNECTION = "Connection"; |
| 136 static final CONTENT_ENCODING = "Content-Encoding"; | 136 static const CONTENT_ENCODING = "Content-Encoding"; |
| 137 static final CONTENT_LANGUAGE = "Content-Language"; | 137 static const CONTENT_LANGUAGE = "Content-Language"; |
| 138 static final CONTENT_LENGTH = "Content-Length"; | 138 static const CONTENT_LENGTH = "Content-Length"; |
| 139 static final CONTENT_LOCATION = "Content-Location"; | 139 static const CONTENT_LOCATION = "Content-Location"; |
| 140 static final CONTENT_MD5 = "Content-MD5"; | 140 static const CONTENT_MD5 = "Content-MD5"; |
| 141 static final CONTENT_RANGE = "Content-Range"; | 141 static const CONTENT_RANGE = "Content-Range"; |
| 142 static final CONTENT_TYPE = "Content-Type"; | 142 static const CONTENT_TYPE = "Content-Type"; |
| 143 static final DATE = "Date"; | 143 static const DATE = "Date"; |
| 144 static final ETAG = "ETag"; | 144 static const ETAG = "ETag"; |
| 145 static final EXPECT = "Expect"; | 145 static const EXPECT = "Expect"; |
| 146 static final EXPIRES = "Expires"; | 146 static const EXPIRES = "Expires"; |
| 147 static final FROM = "From"; | 147 static const FROM = "From"; |
| 148 static final HOST = "Host"; | 148 static const HOST = "Host"; |
| 149 static final IF_MATCH = "If-Match"; | 149 static const IF_MATCH = "If-Match"; |
| 150 static final IF_MODIFIED_SINCE = "If-Modified-Since"; | 150 static const IF_MODIFIED_SINCE = "If-Modified-Since"; |
| 151 static final IF_NONE_MATCH = "If-None-Match"; | 151 static const IF_NONE_MATCH = "If-None-Match"; |
| 152 static final IF_RANGE = "If-Range"; | 152 static const IF_RANGE = "If-Range"; |
| 153 static final IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; | 153 static const IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; |
| 154 static final LAST_MODIFIED = "Last-Modified"; | 154 static const LAST_MODIFIED = "Last-Modified"; |
| 155 static final LOCATION = "Location"; | 155 static const LOCATION = "Location"; |
| 156 static final MAX_FORWARDS = "Max-Forwards"; | 156 static const MAX_FORWARDS = "Max-Forwards"; |
| 157 static final PRAGMA = "Pragma"; | 157 static const PRAGMA = "Pragma"; |
| 158 static final PROXY_AUTHENTICATE = "Proxy-Authenticate"; | 158 static const PROXY_AUTHENTICATE = "Proxy-Authenticate"; |
| 159 static final PROXY_AUTHORIZATION = "Proxy-Authorization"; | 159 static const PROXY_AUTHORIZATION = "Proxy-Authorization"; |
| 160 static final RANGE = "Range"; | 160 static const RANGE = "Range"; |
| 161 static final REFERER = "Referer"; | 161 static const REFERER = "Referer"; |
| 162 static final RETRY_AFTER = "Retry-After"; | 162 static const RETRY_AFTER = "Retry-After"; |
| 163 static final SERVER = "Server"; | 163 static const SERVER = "Server"; |
| 164 static final TE = "TE"; | 164 static const TE = "TE"; |
| 165 static final TRAILER = "Trailer"; | 165 static const TRAILER = "Trailer"; |
| 166 static final TRANSFER_ENCODING = "Transfer-Encoding"; | 166 static const TRANSFER_ENCODING = "Transfer-Encoding"; |
| 167 static final UPGRADE = "Upgrade"; | 167 static const UPGRADE = "Upgrade"; |
| 168 static final USER_AGENT = "User-Agent"; | 168 static const USER_AGENT = "User-Agent"; |
| 169 static final VARY = "Vary"; | 169 static const VARY = "Vary"; |
| 170 static final VIA = "Via"; | 170 static const VIA = "Via"; |
| 171 static final WARNING = "Warning"; | 171 static const WARNING = "Warning"; |
| 172 static final WWW_AUTHENTICATE = "WWW-Authenticate"; | 172 static const WWW_AUTHENTICATE = "WWW-Authenticate"; |
| 173 | 173 |
| 174 static final GENERAL_HEADERS = const [CACHE_CONTROL, | 174 static const GENERAL_HEADERS = const [CACHE_CONTROL, |
| 175 CONNECTION, | 175 CONNECTION, |
| 176 DATE, | 176 DATE, |
| 177 PRAGMA, | 177 PRAGMA, |
| 178 TRAILER, | 178 TRAILER, |
| 179 TRANSFER_ENCODING, | 179 TRANSFER_ENCODING, |
| 180 UPGRADE, | 180 UPGRADE, |
| 181 VIA, | 181 VIA, |
| 182 WARNING]; | 182 WARNING]; |
| 183 | 183 |
| 184 static final ENTITY_HEADERS = const [ALLOW, | 184 static const ENTITY_HEADERS = const [ALLOW, |
| 185 CONTENT-ENCODING, | 185 CONTENT-ENCODING, |
| 186 CONTENT-LANGUAGE, | 186 CONTENT-LANGUAGE, |
| 187 CONTENT-LENGTH, | 187 CONTENT-LENGTH, |
| 188 CONTENT-LOCATION, | 188 CONTENT-LOCATION, |
| 189 CONTENT-MD5, | 189 CONTENT-MD5, |
| 190 CONTENT-RANGE, | 190 CONTENT-RANGE, |
| 191 CONTENT-TYPE, | 191 CONTENT-TYPE, |
| 192 EXPIRES, | 192 EXPIRES, |
| 193 LAST-MODIFIED]; | 193 LAST-MODIFIED]; |
| 194 | 194 |
| 195 | 195 |
| 196 static final RESPONSE_HEADERS = const [ACCEPT-RANGES, | 196 static const RESPONSE_HEADERS = const [ACCEPT-RANGES, |
| 197 AGE, | 197 AGE, |
| 198 ETAG, | 198 ETAG, |
| 199 LOCATION, | 199 LOCATION, |
| 200 PROXY-AUTHENTICATE, | 200 PROXY-AUTHENTICATE, |
| 201 RETRY-AFTER, | 201 RETRY-AFTER, |
| 202 SERVER, | 202 SERVER, |
| 203 VARY, | 203 VARY, |
| 204 WWW-AUTHENTICATE]; | 204 WWW-AUTHENTICATE]; |
| 205 | 205 |
| 206 static final REQUEST_HEADERS = const [ACCEPT, | 206 static const REQUEST_HEADERS = const [ACCEPT, |
| 207 ACCEPT-CHARSET, | 207 ACCEPT-CHARSET, |
| 208 ACCEPT-ENCODING, | 208 ACCEPT-ENCODING, |
| 209 ACCEPT-LANGUAGE, | 209 ACCEPT-LANGUAGE, |
| 210 AUTHORIZATION, | 210 AUTHORIZATION, |
| 211 EXPECT, | 211 EXPECT, |
| 212 FROM, | 212 FROM, |
| 213 HOST, | 213 HOST, |
| 214 IF-MATCH, | 214 IF-MATCH, |
| 215 IF-MODIFIED-SINCE, | 215 IF-MODIFIED-SINCE, |
| 216 IF-NONE-MATCH, | 216 IF-NONE-MATCH, |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 /** | 643 /** |
| 644 * HTTP client factory. The [HttpClient] handles all the sockets associated | 644 * HTTP client factory. The [HttpClient] handles all the sockets associated |
| 645 * with the [HttpClientConnection]s and when the endpoint supports it, it will | 645 * with the [HttpClientConnection]s and when the endpoint supports it, it will |
| 646 * try to reuse opened sockets for several requests to support HTTP 1.1 | 646 * try to reuse opened sockets for several requests to support HTTP 1.1 |
| 647 * persistent connections. This means that sockets will be kept open for some | 647 * persistent connections. This means that sockets will be kept open for some |
| 648 * time after a requests have completed, unless HTTP procedures indicate that it | 648 * time after a requests have completed, unless HTTP procedures indicate that it |
| 649 * must be closed as part of completing the request. Use [:HttpClient.shutdown:] | 649 * must be closed as part of completing the request. Use [:HttpClient.shutdown:] |
| 650 * to force close the idle sockets. | 650 * to force close the idle sockets. |
| 651 */ | 651 */ |
| 652 interface HttpClient default _HttpClient { | 652 interface HttpClient default _HttpClient { |
| 653 static final int DEFAULT_HTTP_PORT = 80; | 653 static const int DEFAULT_HTTP_PORT = 80; |
| 654 | 654 |
| 655 HttpClient(); | 655 HttpClient(); |
| 656 | 656 |
| 657 /** | 657 /** |
| 658 * Opens a HTTP connection. The returned [HttpClientConnection] is | 658 * Opens a HTTP connection. The returned [HttpClientConnection] is |
| 659 * used to register callbacks for asynchronous events on the HTTP | 659 * used to register callbacks for asynchronous events on the HTTP |
| 660 * connection. The "Host" header for the request will be set to the | 660 * connection. The "Host" header for the request will be set to the |
| 661 * value [host]:[port]. This can be overridden through the | 661 * value [host]:[port]. This can be overridden through the |
| 662 * HttpClientRequest interface before the request is sent. NOTE if | 662 * HttpClientRequest interface before the request is sent. NOTE if |
| 663 * [host] is an IP address this will still be set in the "Host" | 663 * [host] is an IP address this will still be set in the "Host" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 class RedirectLimitExceededException extends RedirectException { | 934 class RedirectLimitExceededException extends RedirectException { |
| 935 const RedirectLimitExceededException(List<RedirectInfo> redirects) | 935 const RedirectLimitExceededException(List<RedirectInfo> redirects) |
| 936 : super("Redirect limit exceeded", redirects); | 936 : super("Redirect limit exceeded", redirects); |
| 937 } | 937 } |
| 938 | 938 |
| 939 | 939 |
| 940 class RedirectLoopException extends RedirectException { | 940 class RedirectLoopException extends RedirectException { |
| 941 const RedirectLoopException(List<RedirectInfo> redirects) | 941 const RedirectLoopException(List<RedirectInfo> redirects) |
| 942 : super("Redirect loop detected", redirects); | 942 : super("Redirect loop detected", redirects); |
| 943 } | 943 } |
| OLD | NEW |