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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/http.dart
diff --git a/runtime/bin/http.dart b/runtime/bin/http.dart
index 13b28dcb100892c25b0278c2cf8e1eb6aac2eb93..49ff449b298bd4964fd752f7e7dc68f0970f9dac 100644
--- a/runtime/bin/http.dart
+++ b/runtime/bin/http.dart
@@ -370,8 +370,10 @@ abstract class HeaderValue {
* Creates a new header value object from parsing a header value
* string with both value and optional parameters.
*/
- factory HeaderValue.fromString(String value) {
- return new _HeaderValue.fromString(value);
+ factory HeaderValue.fromString(String value,
+ {String parameterSeparator: ";"}) {
+ return new _HeaderValue.fromString(
+ value, parameterSeparator: parameterSeparator);
}
/**
@@ -747,6 +749,29 @@ abstract class HttpClient {
HttpClientConnection postUrl(Uri url);
/**
+ * Sets the function to be called when a site is requesting
+ * authentication. The URL requested and the security realm from the
+ * server are passed in the arguments [url] and [realm].
+ *
+ * The function returns a [Future] which should complete when the
+ * authentication have been resolved. If credentials cannot be
Mads Ager (google) 2012/10/26 13:53:20 have -> has
+ * provided the [Future] should complete with [false]. If
+ * credentials are available the function should add these using
+ * [addCredentials] before completing the [Future] with the value
+ * [true].
+ *
+ * If the [Future] completes with true the request will be retried
+ * using the updated credentials. Otherwise response processing will
+ * continue normally.
+ */
+ set authenticate(Future<bool> f(Uri url, String scheme, String realm));
+
+ /**
+ * Add credentials to be used for authorizing HTTP requests.
+ */
+ void addCredentials(Uri url, String realm, HttpClientCredentials credentials);
+
+ /**
* Sets the function used to resolve the proxy server to be used for
* opening a HTTP connection to the specified [url]. If this
* function is not set, direct connections will always be used.
@@ -942,6 +967,28 @@ abstract class HttpClientResponse {
InputStream get inputStream;
}
+
+abstract class HttpClientCredentials { }
+
+
+/**
+ * Represent credentials for basic authentication.
+ */
+abstract class HttpClientBasicCredentials extends HttpClientCredentials {
+ factory HttpClientBasicCredentials(String username, String password) =>
+ new _HttpClientBasicCredentials(username, password);
+}
+
+
+/**
+ * Represent credentials for digest authentication.
+ */
+abstract class HttpClientDigestCredentials extends HttpClientCredentials {
+ factory HttpClientDigestCredentials(String username, String password) =>
+ new _HttpClientDigestCredentials(username, password);
+}
+
+
/**
* Connection information.
*/
« 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