Chromium Code Reviews| Index: sdk/lib/io/http_impl.dart |
| diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart |
| index c78348120f47f71707b21bc1294a9265091b81a1..91217c2ae96a9679854ce16ff59baa700a3afc62 100644 |
| --- a/sdk/lib/io/http_impl.dart |
| +++ b/sdk/lib/io/http_impl.dart |
| @@ -1704,7 +1704,7 @@ class _HttpClient implements HttpClient { |
| HttpClientConnection _openUrl(String method, |
| Uri url, |
| [_HttpClientConnection connection]) { |
| - if (url.scheme != "http") { |
| + if (url.scheme != "http" && url.scheme != "https") { |
| throw new HttpException("Unsupported URL scheme ${url.scheme}"); |
| } |
| return _open(method, url, connection); |
| @@ -1769,7 +1769,8 @@ class _HttpClient implements HttpClient { |
| int port, |
| _ProxyConfiguration proxyConfiguration, |
| int proxyIndex, |
| - bool reusedConnection) { |
| + bool reusedConnection, |
| + bool secure) { |
| void _connectionOpened(_SocketConnection socketConn, |
| _HttpClientConnection connection, |
| @@ -1822,7 +1823,8 @@ class _HttpClient implements HttpClient { |
| String key = _connectionKey(connectHost, connectPort); |
| Queue socketConnections = _openSockets[key]; |
|
Søren Gjesse
2012/11/28 12:36:30
How about removing all incompatible sockets here?
Bill Hesse
2012/11/28 14:11:23
Done.
Bill Hesse
2012/11/28 14:11:23
Done.
|
| if (socketConnections == null || socketConnections.isEmpty) { |
| - Socket socket = new Socket(connectHost, connectPort); |
| + Socket socket = secure ? new SecureSocket(connectHost, connectPort) : |
| + new Socket(connectHost, connectPort); |
| // Until the connection is established handle connection errors |
| // here as the HttpClientConnection object is not yet associated |
| // with the socket. |
| @@ -1845,12 +1847,18 @@ class _HttpClient implements HttpClient { |
| // the connected socket. |
| socket.onError = null; |
| _SocketConnection socketConn = |
| - new _SocketConnection(connectHost, connectPort, socket); |
| + new _SocketConnection(connectHost, connectPort, socket); |
| _activeSockets.add(socketConn); |
| _connectionOpened(socketConn, connection, !proxy.isDirect); |
| }; |
| } else { |
| _SocketConnection socketConn = socketConnections.removeFirst(); |
| + if (secure != (socketConn._socket is SecureSocket)) { |
|
Søren Gjesse
2012/11/28 12:36:30
If you get rid of incompatible connections above t
Bill Hesse
2012/11/28 14:11:23
Done.
|
| + // TODO(whesse): Clear the socketConnections for this key, and retry. |
| + connection._onError(new SocketIOException( |
| + "Secure and insecure connection made to the same host and port", |
| + null)); |
| + } |
| _activeSockets.add(socketConn); |
| new Timer(0, (ignored) => |
| _connectionOpened(socketConn, connection, !proxy.isDirect)); |
| @@ -1861,10 +1869,17 @@ class _HttpClient implements HttpClient { |
| } |
| } |
| + // Find out if we want a secure socket. |
| + bool secure = (url.scheme == "https"); |
| + |
| // Find the TCP host and port. |
| String host = url.domain; |
| - int port = url.port == 0 ? HttpClient.DEFAULT_HTTP_PORT : url.port; |
| - |
| + int port = url.port; |
| + if (port == 0) { |
| + port = secure ? |
| + HttpClient.DEFAULT_HTTPS_PORT : |
| + HttpClient.DEFAULT_HTTP_PORT; |
| + } |
| // Create a new connection object if we are not re-using an existing one. |
| var reusedConnection = false; |
| if (connection == null) { |
| @@ -1883,7 +1898,12 @@ class _HttpClient implements HttpClient { |
| } |
| // Establish the connection starting with the first proxy configured. |
| - _establishConnection(host, port, proxyConfiguration, 0, reusedConnection); |
| + _establishConnection(host, |
| + port, |
| + proxyConfiguration, |
| + 0, |
| + reusedConnection, |
| + secure); |
| return connection; |
| } |