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

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 review comments from ajohnsen@ 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 abstract class HeaderValue { 363 abstract class HeaderValue {
364 /** 364 /**
365 * Creates a new header value object setting the value part. 365 * Creates a new header value object setting the value part.
366 */ 366 */
367 factory HeaderValue([String value = ""]) => new _HeaderValue(value); 367 factory HeaderValue([String value = ""]) => new _HeaderValue(value);
368 368
369 /** 369 /**
370 * Creates a new header value object from parsing a header value 370 * Creates a new header value object from parsing a header value
371 * string with both value and optional parameters. 371 * string with both value and optional parameters.
372 */ 372 */
373 factory HeaderValue.fromString(String value) { 373 factory HeaderValue.fromString(String value,
374 return new _HeaderValue.fromString(value); 374 {String parameterSeparator: ";"}) {
375 return new _HeaderValue.fromString(
376 value, parameterSeparator: parameterSeparator);
375 } 377 }
376 378
377 /** 379 /**
378 * Gets and sets the header value. 380 * Gets and sets the header value.
379 */ 381 */
380 String value; 382 String value;
381 383
382 /** 384 /**
383 * Gets the map of parameters. 385 * Gets the map of parameters.
384 */ 386 */
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 * Opens a HTTP connection using the POST method. See [open] for details. 742 * Opens a HTTP connection using the POST method. See [open] for details.
741 */ 743 */
742 HttpClientConnection post(String host, int port, String path); 744 HttpClientConnection post(String host, int port, String path);
743 745
744 /** 746 /**
745 * Opens a HTTP connection using the POST method. See [openUrl] for details. 747 * Opens a HTTP connection using the POST method. See [openUrl] for details.
746 */ 748 */
747 HttpClientConnection postUrl(Uri url); 749 HttpClientConnection postUrl(Uri url);
748 750
749 /** 751 /**
752 * Sets the function to be called when a site is requesting
753 * authentication. The URL requested and the security realm from the
754 * server are passed in the arguments [url] and [realm].
755 *
756 * The function returns a [Future] which should complete when the
757 * authentication have been resolved. If credentials cannot be
Mads Ager (google) 2012/10/26 13:53:20 have -> has
758 * provided the [Future] should complete with [false]. If
759 * credentials are available the function should add these using
760 * [addCredentials] before completing the [Future] with the value
761 * [true].
762 *
763 * If the [Future] completes with true the request will be retried
764 * using the updated credentials. Otherwise response processing will
765 * continue normally.
766 */
767 set authenticate(Future<bool> f(Uri url, String scheme, String realm));
768
769 /**
770 * Add credentials to be used for authorizing HTTP requests.
771 */
772 void addCredentials(Uri url, String realm, HttpClientCredentials credentials);
773
774 /**
750 * Sets the function used to resolve the proxy server to be used for 775 * Sets the function used to resolve the proxy server to be used for
751 * opening a HTTP connection to the specified [url]. If this 776 * opening a HTTP connection to the specified [url]. If this
752 * function is not set, direct connections will always be used. 777 * function is not set, direct connections will always be used.
753 * 778 *
754 * The string returned by [f] must be in the format used by browser 779 * The string returned by [f] must be in the format used by browser
755 * PAC (proxy auto-config) scripts. That is either 780 * PAC (proxy auto-config) scripts. That is either
756 * 781 *
757 * "DIRECT" 782 * "DIRECT"
758 * 783 *
759 * for using a direct connection or 784 * for using a direct connection or
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 */ 960 */
936 List<Cookie> get cookies; 961 List<Cookie> get cookies;
937 962
938 /** 963 /**
939 * Returns the input stream for the response. This is used to read 964 * Returns the input stream for the response. This is used to read
940 * the response data. 965 * the response data.
941 */ 966 */
942 InputStream get inputStream; 967 InputStream get inputStream;
943 } 968 }
944 969
970
971 abstract class HttpClientCredentials { }
972
973
974 /**
975 * Represent credentials for basic authentication.
976 */
977 abstract class HttpClientBasicCredentials extends HttpClientCredentials {
978 factory HttpClientBasicCredentials(String username, String password) =>
979 new _HttpClientBasicCredentials(username, password);
980 }
981
982
983 /**
984 * Represent credentials for digest authentication.
985 */
986 abstract class HttpClientDigestCredentials extends HttpClientCredentials {
987 factory HttpClientDigestCredentials(String username, String password) =>
988 new _HttpClientDigestCredentials(username, password);
989 }
990
991
945 /** 992 /**
946 * Connection information. 993 * Connection information.
947 */ 994 */
948 abstract class HttpConnectionInfo { 995 abstract class HttpConnectionInfo {
949 String get remoteHost; 996 String get remoteHost;
950 int get remotePort; 997 int get remotePort;
951 int get localPort; 998 int get localPort;
952 } 999 }
953 1000
954 1001
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 class RedirectLimitExceededException extends RedirectException { 1050 class RedirectLimitExceededException extends RedirectException {
1004 const RedirectLimitExceededException(List<RedirectInfo> redirects) 1051 const RedirectLimitExceededException(List<RedirectInfo> redirects)
1005 : super("Redirect limit exceeded", redirects); 1052 : super("Redirect limit exceeded", redirects);
1006 } 1053 }
1007 1054
1008 1055
1009 class RedirectLoopException extends RedirectException { 1056 class RedirectLoopException extends RedirectException {
1010 const RedirectLoopException(List<RedirectInfo> redirects) 1057 const RedirectLoopException(List<RedirectInfo> redirects)
1011 : super("Redirect loop detected", redirects); 1058 : super("Redirect loop detected", redirects);
1012 } 1059 }
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