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 final int CONTINUE = 100; |
10 static final int SWITCHING_PROTOCOLS = 101; | 10 static final int SWITCHING_PROTOCOLS = 101; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 */ | 170 */ |
171 int statusCode; | 171 int statusCode; |
172 | 172 |
173 /** | 173 /** |
174 * Gets and sets the reason phrase. If no reason phrase is explicitly | 174 * Gets and sets the reason phrase. If no reason phrase is explicitly |
175 * set a default reason phrase is provided. | 175 * set a default reason phrase is provided. |
176 */ | 176 */ |
177 String reasonPhrase; | 177 String reasonPhrase; |
178 | 178 |
179 /** | 179 /** |
| 180 * Gets and sets the expiry date. The value of this property will |
| 181 * reflect the "Expires" header |
| 182 */ |
| 183 Date expires; |
| 184 |
| 185 /** |
180 * Sets a header on the response. NOTE: If the same header name is | 186 * Sets a header on the response. NOTE: If the same header name is |
181 * set more than once only the last value will be part of the | 187 * set more than once only the last value will be part of the |
182 * response. | 188 * response. |
183 */ | 189 */ |
184 void setHeader(String name, String value); | 190 void setHeader(String name, String value); |
185 | 191 |
186 /** | 192 /** |
187 * Returns the output stream for the response. This is used to write | 193 * Returns the output stream for the response. This is used to write |
188 * the response data. When all response data has been written close | 194 * the response data. When all response data has been written close |
189 * the stream to indicate the end of the response. | 195 * the stream to indicate the end of the response. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 * the request body is not known in advance this -1. | 335 * the request body is not known in advance this -1. |
330 */ | 336 */ |
331 int get contentLength(); | 337 int get contentLength(); |
332 | 338 |
333 /** | 339 /** |
334 * Returns the keep alive state of the connection. | 340 * Returns the keep alive state of the connection. |
335 */ | 341 */ |
336 bool get keepAlive(); | 342 bool get keepAlive(); |
337 | 343 |
338 /** | 344 /** |
| 345 * Returns the date value for the "Expires" header. Returns null if |
| 346 * the response has no "Expires" header. Throws a HttpException if |
| 347 * the response has an "Expires" header which is not formatted as a |
| 348 * valid HTTP date. |
| 349 */ |
| 350 Date get expires(); |
| 351 |
| 352 /** |
339 * Returns the response headers. | 353 * Returns the response headers. |
340 */ | 354 */ |
341 Map get headers(); | 355 Map get headers(); |
342 | 356 |
343 /** | 357 /** |
344 * Returns the input stream for the response. This is used to read | 358 * Returns the input stream for the response. This is used to read |
345 * the response data. | 359 * the response data. |
346 */ | 360 */ |
347 InputStream get inputStream(); | 361 InputStream get inputStream(); |
348 } | 362 } |
349 | 363 |
350 | 364 |
351 class HttpException implements Exception { | 365 class HttpException implements Exception { |
352 const HttpException([String this.message = ""]); | 366 const HttpException([String this.message = ""]); |
353 String toString() => "HttpException: $message"; | 367 String toString() => "HttpException: $message"; |
354 final String message; | 368 final String message; |
355 } | 369 } |
OLD | NEW |