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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 22816008: dart:io | Add badCertificateCallback to HttpClient. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve documentation comments. Created 7 years, 4 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 | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_bad_certificate_client.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index ca097c9220a5c50c90195ba7492f0a1308b6d9e6..1a5e3a5298e01a3688ee3220a4911c39f309a9d7 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -1335,7 +1335,7 @@ class _HttpClientConnection {
.then((_) => _socket.destroy());
}
- Future<_HttpClientConnection> createProxyTunnel(host, port, proxy) {
+ Future<_HttpClientConnection> createProxyTunnel(host, port, proxy, callback) {
_HttpClientRequest request =
send(new Uri(host: host, port: port),
port,
@@ -1355,7 +1355,8 @@ class _HttpClientConnection {
"(${response.statusCode} ${response.reasonPhrase})";
}
var socket = response._httpRequest._httpClientConnection._socket;
- return SecureSocket.secure(socket, host: host);
+ return SecureSocket.secure(
+ socket, host: host, onBadCertificate: callback);
})
.then((secureSocket) {
String key = _HttpClientConnection.makeKey(true, host, port);
@@ -1409,6 +1410,7 @@ class _HttpClient implements HttpClient {
Function _authenticateProxy;
Function _findProxy = HttpClient.findProxyFromEnvironment;
Duration _idleTimeout = const Duration(seconds: 15);
+ Function _badCertificateCallback;
Timer _noActiveTimer;
@@ -1426,6 +1428,12 @@ class _HttpClient implements HttpClient {
}));
}
+ set badCertificateCallback(bool callback(X509Certificate cert,
+ String host,
+ int port)) {
+ _badCertificateCallback = callback;
+ }
+
Future<HttpClientRequest> open(String method,
String host,
@@ -1674,17 +1682,23 @@ class _HttpClient implements HttpClient {
_updateTimers();
return new Future.value(new _ConnnectionInfo(connection, proxy));
}
+ var currentBadCertificateCallback = _badCertificateCallback;
+ bool callback(X509Certificate certificate) =>
+ currentBadCertificateCallback == null ? false :
+ currentBadCertificateCallback(certificate, uriHost, uriPort);
return (isSecure && proxy.isDirect
? SecureSocket.connect(host,
port,
- sendClientCertificate: true)
+ sendClientCertificate: true,
+ onBadCertificate: callback)
: Socket.connect(host, port))
.then((socket) {
socket.setOption(SocketOption.TCP_NODELAY, true);
var connection = new _HttpClientConnection(key, socket, this);
if (isSecure && !proxy.isDirect) {
connection._dispose = true;
- return connection.createProxyTunnel(uriHost, uriPort, proxy)
+ return connection.createProxyTunnel(
+ uriHost, uriPort, proxy, callback)
.then((tunnel) {
_activeConnections.add(tunnel);
return new _ConnnectionInfo(tunnel, proxy);
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_bad_certificate_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698