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

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

Issue 14083007: Add new InternetAddress class with a static lookup function (including IPv6 results). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix new test. Created 7 years, 8 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_impl.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index 17eb384021d326c3377082a3f1248bbdb901f39a..db82ea4d7b6137bc32ec15c47b7795ae5a2ae50a 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -35,7 +35,7 @@ abstract class SecureSocket implements Socket {
* to continue the [SecureSocket] connection.
*/
static Future<SecureSocket> connect(
- String host,
+ host,
int port,
{bool sendClientCertificate: false,
String certificateName,
@@ -208,7 +208,7 @@ abstract class RawSecureSocket implements RawSocket {
* to continue the [RawSecureSocket] connection.
*/
static Future<RawSecureSocket> connect(
- String host,
+ host,
int port,
{bool sendClientCertificate: false,
String certificateName,
@@ -244,7 +244,7 @@ abstract class RawSecureSocket implements RawSocket {
String certificateName,
bool onBadCertificate(X509Certificate certificate)}) {
return _RawSecureSocket.connect(
- socket.host,
+ socket.address,
socket.port,
certificateName,
is_server: false,
@@ -345,7 +345,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
StreamSubscription<RawSocketEvent> _socketSubscription;
List<int> _carryOverData;
int _carryOverDataIndex = 0;
- final String host;
+ final InternetAddress address;
final bool is_server;
final String certificateName;
final bool requestClientCertificate;
@@ -366,7 +366,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
_SecureFilter _secureFilter = new _SecureFilter();
static Future<_RawSecureSocket> connect(
- String host,
+ host,
int requestedPort,
String certificateName,
{bool is_server,
@@ -376,8 +376,15 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
bool requestClientCertificate: false,
bool requireClientCertificate: false,
bool sendClientCertificate: false,
- bool onBadCertificate(X509Certificate certificate)}){
- return new _RawSecureSocket(host,
+ bool onBadCertificate(X509Certificate certificate)}) {
+ var future;
+ if (host is String) {
+ future = InternetAddress.lookup(host).then((addrs) => addrs.first);
+ } else {
+ future = new Future.value(host);
+ }
+ return future.then((addr) {
+ return new _RawSecureSocket(addr,
requestedPort,
certificateName,
is_server,
@@ -389,10 +396,11 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
sendClientCertificate,
onBadCertificate)
._handshakeComplete.future;
+ });
}
_RawSecureSocket(
- String this.host,
+ InternetAddress this.address,
int requestedPort,
String this.certificateName,
bool this.is_server,
@@ -421,7 +429,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
}
var futureSocket;
if (socket == null) {
- futureSocket = RawSocket.connect(host, requestedPort);
+ futureSocket = RawSocket.connect(address, requestedPort);
} else {
futureSocket = new Future.value(socket);
}
@@ -441,7 +449,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
_socketSubscription.onDone(_doneHandler);
}
_connectPending = true;
- _secureFilter.connect(host,
+ _secureFilter.connect(rawSocket.address.host,
port,
is_server,
certificateName,
@@ -475,9 +483,9 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
void _verifyFields() {
assert(is_server is bool);
assert(_socket == null || _socket is RawSocket);
- if (host is! String) {
+ if (address is! InternetAddress) {
throw new ArgumentError(
- "RawSecureSocket constructor: host is not a String");
+ "RawSecureSocket constructor: host is not an InternetAddress");
}
if (certificateName != null && certificateName is! String) {
throw new ArgumentError("certificateName is not null or a String");
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698