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

Side by Side Diff: runtime/bin/http.dart

Issue 11118021: Add support for authorization of HTTP client requests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed more comments + made the authenticate callback async Created 8 years, 1 month 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 | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 abstract class HttpStatus { 8 abstract class HttpStatus {
9 static const int CONTINUE = 100; 9 static const int CONTINUE = 100;
10 static const int SWITCHING_PROTOCOLS = 101; 10 static const int SWITCHING_PROTOCOLS = 101;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 abstract class HeaderValue { 357 abstract class HeaderValue {
358 /** 358 /**
359 * Creates a new header value object setting the value part. 359 * Creates a new header value object setting the value part.
360 */ 360 */
361 factory HeaderValue([String value = ""]) => new _HeaderValue(value); 361 factory HeaderValue([String value = ""]) => new _HeaderValue(value);
362 362
363 /** 363 /**
364 * Creates a new header value object from parsing a header value 364 * Creates a new header value object from parsing a header value
365 * string with both value and optional parameters. 365 * string with both value and optional parameters.
366 */ 366 */
367 factory HeaderValue.fromString(String value) { 367 factory HeaderValue.fromString(String value,
368 return new _HeaderValue.fromString(value); 368 [String parameterSeparator = ";"]) {
369 return new _HeaderValue.fromString(value, parameterSeparator);
369 } 370 }
370 371
371 /** 372 /**
372 * Gets and sets the header value. 373 * Gets and sets the header value.
373 */ 374 */
374 String value; 375 String value;
375 376
376 /** 377 /**
377 * Gets the map of parameters. 378 * Gets the map of parameters.
378 */ 379 */
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 * Opens a HTTP connection using the POST method. See [open] for details. 703 * Opens a HTTP connection using the POST method. See [open] for details.
703 */ 704 */
704 HttpClientConnection post(String host, int port, String path); 705 HttpClientConnection post(String host, int port, String path);
705 706
706 /** 707 /**
707 * Opens a HTTP connection using the POST method. See [openUrl] for details. 708 * Opens a HTTP connection using the POST method. See [openUrl] for details.
708 */ 709 */
709 HttpClientConnection postUrl(Uri url); 710 HttpClientConnection postUrl(Uri url);
710 711
711 /** 712 /**
713 * Sets the function to be called when a site is requesting
714 * authentication. The URL requested and the security realm from the
715 * server are passed in the arguments [url] and [realm].
716 *
717 * The function returns a [Future] which should complete when the
718 * authentication have been resolved. If credentials cannot be
719 * provided the [Futire] should complete with [false]. If
Anders Johnsen 2012/10/26 13:04:50 Futire->Future
Søren Gjesse 2012/10/26 13:41:06 Done.
720 * credentials are available the function should add these using
721 * [addCredentials] before completing the [Future] with the value
722 * [true].
723 *
724 * If the [Future] completes with true the request will be retried
725 * using the updated credentials. Otherwise response processing will
726 * continue normally.
727 */
728 set authenticate(Future<bool> f(Uri url, String scheme, String realm));
729
730 /**
731 * Add credentials to be used for authorizing HTTP requests.
732 */
733 void addCredentials(Uri url, String realm, HttpClientCredentials credentials);
734
735 /**
712 * Sets the function used to resolve the proxy server to be used for 736 * Sets the function used to resolve the proxy server to be used for
713 * opening a HTTP connection to the specified [url]. If this 737 * opening a HTTP connection to the specified [url]. If this
714 * function is not set, direct connections will always be used. 738 * function is not set, direct connections will always be used.
715 * 739 *
716 * The string returned by [f] must be in the format used by browser 740 * The string returned by [f] must be in the format used by browser
717 * PAC (proxy auto-config) scripts. That is either 741 * PAC (proxy auto-config) scripts. That is either
718 * 742 *
719 * "DIRECT" 743 * "DIRECT"
720 * 744 *
721 * for using a direct connection or 745 * for using a direct connection or
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 */ 921 */
898 List<Cookie> get cookies; 922 List<Cookie> get cookies;
899 923
900 /** 924 /**
901 * Returns the input stream for the response. This is used to read 925 * Returns the input stream for the response. This is used to read
902 * the response data. 926 * the response data.
903 */ 927 */
904 InputStream get inputStream; 928 InputStream get inputStream;
905 } 929 }
906 930
931
932 abstract class HttpClientCredentials { }
933
934
935 /**
936 * Represent credentials for basic authentication.
937 */
938 abstract class HttpClientBasicCredentials extends HttpClientCredentials {
939 factory HttpClientBasicCredentials(String username, String password) =>
940 new _HttpClientBasicCredentials(username, password);
941 }
942
943
944 /**
945 * Represent credentials for digest authentication.
946 */
947 abstract class HttpClientDigestCredentials extends HttpClientCredentials {
948 factory HttpClientDigestCredentials(String username, String password) =>
949 new _HttpClientDigestCredentials(username, password);
950 }
951
952
907 /** 953 /**
908 * Connection information. 954 * Connection information.
909 */ 955 */
910 abstract class HttpConnectionInfo { 956 abstract class HttpConnectionInfo {
911 String get remoteHost; 957 String get remoteHost;
912 int get remotePort; 958 int get remotePort;
913 int get localPort; 959 int get localPort;
914 } 960 }
915 961
916 962
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 class RedirectLimitExceededException extends RedirectException { 1011 class RedirectLimitExceededException extends RedirectException {
966 const RedirectLimitExceededException(List<RedirectInfo> redirects) 1012 const RedirectLimitExceededException(List<RedirectInfo> redirects)
967 : super("Redirect limit exceeded", redirects); 1013 : super("Redirect limit exceeded", redirects);
968 } 1014 }
969 1015
970 1016
971 class RedirectLoopException extends RedirectException { 1017 class RedirectLoopException extends RedirectException {
972 const RedirectLoopException(List<RedirectInfo> redirects) 1018 const RedirectLoopException(List<RedirectInfo> redirects)
973 : super("Redirect loop detected", redirects); 1019 : super("Redirect loop detected", redirects);
974 } 1020 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698