| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * HTTP status codes. | 8 * HTTP status codes. |
| 9 */ | 9 */ |
| 10 abstract class HttpStatus { | 10 abstract class HttpStatus { |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 951 |
| 952 /** | 952 /** |
| 953 * The method, such as 'GET' or 'POST', for the request. | 953 * The method, such as 'GET' or 'POST', for the request. |
| 954 */ | 954 */ |
| 955 String get method; | 955 String get method; |
| 956 | 956 |
| 957 /** | 957 /** |
| 958 * The URI for the request. | 958 * The URI for the request. |
| 959 * | 959 * |
| 960 * This provides access to the | 960 * This provides access to the |
| 961 * path, query string, and fragment identifier for the request. | 961 * path and query string for the request. |
| 962 */ | 962 */ |
| 963 Uri get uri; | 963 Uri get uri; |
| 964 | 964 |
| 965 /** | 965 /** |
| 966 * The requested URI for the request. | 966 * The requested URI for the request. |
| 967 * | 967 * |
| 968 * The returend URI is reconstructed by using http-header fields, to access | 968 * The returend URI is reconstructed by using http-header fields, to access |
| 969 * otherwise lost information, e.g. host and scheme. | 969 * otherwise lost information, e.g. host and scheme. |
| 970 * | 970 * |
| 971 * To reconstruct the scheme, first 'X-Forwarded-Proto' is checked, and then | 971 * To reconstruct the scheme, first 'X-Forwarded-Proto' is checked, and then |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 */ | 1331 */ |
| 1332 String userAgent; | 1332 String userAgent; |
| 1333 | 1333 |
| 1334 factory HttpClient() => new _HttpClient(); | 1334 factory HttpClient() => new _HttpClient(); |
| 1335 | 1335 |
| 1336 /** | 1336 /** |
| 1337 * Opens a HTTP connection. | 1337 * Opens a HTTP connection. |
| 1338 * | 1338 * |
| 1339 * The HTTP method to use is specified in [method], the server is | 1339 * The HTTP method to use is specified in [method], the server is |
| 1340 * specified using [host] and [port], and the path (including | 1340 * specified using [host] and [port], and the path (including |
| 1341 * possible fragment and query) is specified using [path]. | 1341 * a possible query) is specified using [path]. |
| 1342 * The path may also contain a URI fragment, which will be ignored. |
| 1342 * | 1343 * |
| 1343 * The `Host` header for the request will be set to the value | 1344 * The `Host` header for the request will be set to the value |
| 1344 * [host]:[port]. This can be overridden through the | 1345 * [host]:[port]. This can be overridden through the |
| 1345 * [HttpClientRequest] interface before the request is sent. NOTE | 1346 * [HttpClientRequest] interface before the request is sent. NOTE |
| 1346 * if [host] is an IP address this will still be set in the `Host` | 1347 * if [host] is an IP address this will still be set in the `Host` |
| 1347 * header. | 1348 * header. |
| 1348 * | 1349 * |
| 1349 * For additional information on the sequence of events during an | 1350 * For additional information on the sequence of events during an |
| 1350 * HTTP transaction, and the objects returned by the futures, see | 1351 * HTTP transaction, and the objects returned by the futures, see |
| 1351 * the overall documentation for the class [HttpClient]. | 1352 * the overall documentation for the class [HttpClient]. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1370 * For additional information on the sequence of events during an | 1371 * For additional information on the sequence of events during an |
| 1371 * HTTP transaction, and the objects returned by the futures, see | 1372 * HTTP transaction, and the objects returned by the futures, see |
| 1372 * the overall documentation for the class [HttpClient]. | 1373 * the overall documentation for the class [HttpClient]. |
| 1373 */ | 1374 */ |
| 1374 Future<HttpClientRequest> openUrl(String method, Uri url); | 1375 Future<HttpClientRequest> openUrl(String method, Uri url); |
| 1375 | 1376 |
| 1376 /** | 1377 /** |
| 1377 * Opens a HTTP connection using the GET method. | 1378 * Opens a HTTP connection using the GET method. |
| 1378 * | 1379 * |
| 1379 * The server is specified using [host] and [port], and the path | 1380 * The server is specified using [host] and [port], and the path |
| 1380 * (including possible fragment and query) is specified using | 1381 * (including a possible query) is specified using |
| 1381 * [path]. | 1382 * [path]. |
| 1382 * | 1383 * |
| 1383 * See [open] for details. | 1384 * See [open] for details. |
| 1384 */ | 1385 */ |
| 1385 Future<HttpClientRequest> get(String host, int port, String path); | 1386 Future<HttpClientRequest> get(String host, int port, String path); |
| 1386 | 1387 |
| 1387 /** | 1388 /** |
| 1388 * Opens a HTTP connection using the GET method. | 1389 * Opens a HTTP connection using the GET method. |
| 1389 * | 1390 * |
| 1390 * The URL to use is specified in [url]. | 1391 * The URL to use is specified in [url]. |
| 1391 * | 1392 * |
| 1392 * See [openUrl] for details. | 1393 * See [openUrl] for details. |
| 1393 */ | 1394 */ |
| 1394 Future<HttpClientRequest> getUrl(Uri url); | 1395 Future<HttpClientRequest> getUrl(Uri url); |
| 1395 | 1396 |
| 1396 /** | 1397 /** |
| 1397 * Opens a HTTP connection using the POST method. | 1398 * Opens a HTTP connection using the POST method. |
| 1398 * | 1399 * |
| 1399 * The server is specified using [host] and [port], and the path | 1400 * The server is specified using [host] and [port], and the path |
| 1400 * (including possible fragment and query) is specified using | 1401 * (including a possible query) is specified using |
| 1401 * [path]. | 1402 * [path]. |
| 1402 * | 1403 * |
| 1403 * See [open] for details. | 1404 * See [open] for details. |
| 1404 */ | 1405 */ |
| 1405 Future<HttpClientRequest> post(String host, int port, String path); | 1406 Future<HttpClientRequest> post(String host, int port, String path); |
| 1406 | 1407 |
| 1407 /** | 1408 /** |
| 1408 * Opens a HTTP connection using the POST method. | 1409 * Opens a HTTP connection using the POST method. |
| 1409 * | 1410 * |
| 1410 * The URL to use is specified in [url]. | 1411 * The URL to use is specified in [url]. |
| 1411 * | 1412 * |
| 1412 * See [openUrl] for details. | 1413 * See [openUrl] for details. |
| 1413 */ | 1414 */ |
| 1414 Future<HttpClientRequest> postUrl(Uri url); | 1415 Future<HttpClientRequest> postUrl(Uri url); |
| 1415 | 1416 |
| 1416 /** | 1417 /** |
| 1417 * Opens a HTTP connection using the PUT method. | 1418 * Opens a HTTP connection using the PUT method. |
| 1418 * | 1419 * |
| 1419 * The server is specified using [host] and [port], and the path | 1420 * The server is specified using [host] and [port], and the path |
| 1420 * (including possible fragment and query) is specified using | 1421 * (including a possible query) is specified using [path]. |
| 1421 * [path]. | |
| 1422 * | 1422 * |
| 1423 * See [open] for details. | 1423 * See [open] for details. |
| 1424 */ | 1424 */ |
| 1425 Future<HttpClientRequest> put(String host, int port, String path); | 1425 Future<HttpClientRequest> put(String host, int port, String path); |
| 1426 | 1426 |
| 1427 /** | 1427 /** |
| 1428 * Opens a HTTP connection using the PUT method. | 1428 * Opens a HTTP connection using the PUT method. |
| 1429 * | 1429 * |
| 1430 * The URL to use is specified in [url]. | 1430 * The URL to use is specified in [url]. |
| 1431 * | 1431 * |
| 1432 * See [openUrl] for details. | 1432 * See [openUrl] for details. |
| 1433 */ | 1433 */ |
| 1434 Future<HttpClientRequest> putUrl(Uri url); | 1434 Future<HttpClientRequest> putUrl(Uri url); |
| 1435 | 1435 |
| 1436 /** | 1436 /** |
| 1437 * Opens a HTTP connection using the DELETE method. | 1437 * Opens a HTTP connection using the DELETE method. |
| 1438 * | 1438 * |
| 1439 * The server is specified using [host] and [port], and the path | 1439 * The server is specified using [host] and [port], and the path |
| 1440 * (including possible fragment and query) is specified using | 1440 * (including s possible query) is specified using [path]. |
| 1441 * [path]. | |
| 1442 * | 1441 * |
| 1443 * See [open] for details. | 1442 * See [open] for details. |
| 1444 */ | 1443 */ |
| 1445 Future<HttpClientRequest> delete(String host, int port, String path); | 1444 Future<HttpClientRequest> delete(String host, int port, String path); |
| 1446 | 1445 |
| 1447 /** | 1446 /** |
| 1448 * Opens a HTTP connection using the DELETE method. | 1447 * Opens a HTTP connection using the DELETE method. |
| 1449 * | 1448 * |
| 1450 * The URL to use is specified in [url]. | 1449 * The URL to use is specified in [url]. |
| 1451 * | 1450 * |
| 1452 * See [openUrl] for details. | 1451 * See [openUrl] for details. |
| 1453 */ | 1452 */ |
| 1454 Future<HttpClientRequest> deleteUrl(Uri url); | 1453 Future<HttpClientRequest> deleteUrl(Uri url); |
| 1455 | 1454 |
| 1456 /** | 1455 /** |
| 1457 * Opens a HTTP connection using the PATCH method. | 1456 * Opens a HTTP connection using the PATCH method. |
| 1458 * | 1457 * |
| 1459 * The server is specified using [host] and [port], and the path | 1458 * The server is specified using [host] and [port], and the path |
| 1460 * (including possible fragment and query) is specified using | 1459 * (including a possible query) is specified using [path]. |
| 1461 * [path]. | |
| 1462 * | 1460 * |
| 1463 * See [open] for details. | 1461 * See [open] for details. |
| 1464 */ | 1462 */ |
| 1465 Future<HttpClientRequest> patch(String host, int port, String path); | 1463 Future<HttpClientRequest> patch(String host, int port, String path); |
| 1466 | 1464 |
| 1467 /** | 1465 /** |
| 1468 * Opens a HTTP connection using the PATCH method. | 1466 * Opens a HTTP connection using the PATCH method. |
| 1469 * | 1467 * |
| 1470 * The URL to use is specified in [url]. | 1468 * The URL to use is specified in [url]. |
| 1471 * | 1469 * |
| 1472 * See [openUrl] for details. | 1470 * See [openUrl] for details. |
| 1473 */ | 1471 */ |
| 1474 Future<HttpClientRequest> patchUrl(Uri url); | 1472 Future<HttpClientRequest> patchUrl(Uri url); |
| 1475 | 1473 |
| 1476 /** | 1474 /** |
| 1477 * Opens a HTTP connection using the HEAD method. | 1475 * Opens a HTTP connection using the HEAD method. |
| 1478 * | 1476 * |
| 1479 * The server is specified using [host] and [port], and the path | 1477 * The server is specified using [host] and [port], and the path |
| 1480 * (including possible fragment and query) is specified using | 1478 * (including a possible query) is specified using [path]. |
| 1481 * [path]. | |
| 1482 * | 1479 * |
| 1483 * See [open] for details. | 1480 * See [open] for details. |
| 1484 */ | 1481 */ |
| 1485 Future<HttpClientRequest> head(String host, int port, String path); | 1482 Future<HttpClientRequest> head(String host, int port, String path); |
| 1486 | 1483 |
| 1487 /** | 1484 /** |
| 1488 * Opens a HTTP connection using the HEAD method. | 1485 * Opens a HTTP connection using the HEAD method. |
| 1489 * | 1486 * |
| 1490 * The URL to use is specified in [url]. | 1487 * The URL to use is specified in [url]. |
| 1491 * | 1488 * |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 class RedirectException implements HttpException { | 2007 class RedirectException implements HttpException { |
| 2011 final String message; | 2008 final String message; |
| 2012 final List<RedirectInfo> redirects; | 2009 final List<RedirectInfo> redirects; |
| 2013 | 2010 |
| 2014 const RedirectException(this.message, this.redirects); | 2011 const RedirectException(this.message, this.redirects); |
| 2015 | 2012 |
| 2016 String toString() => "RedirectException: $message"; | 2013 String toString() => "RedirectException: $message"; |
| 2017 | 2014 |
| 2018 Uri get uri => redirects.last.location; | 2015 Uri get uri => redirects.last.location; |
| 2019 } | 2016 } |
| OLD | NEW |