Index: net/socket/ssl_client_socket_win.cc |
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc |
index 37e5309c786d3e25078626b49f5afefa972f1ccb..bde754a9b9b0dca2809a583452c30c18fd526fe8 100644 |
--- a/net/socket/ssl_client_socket_win.cc |
+++ b/net/socket/ssl_client_socket_win.cc |
@@ -702,16 +702,30 @@ void SSLClientSocketWin::Disconnect() { |
} |
bool SSLClientSocketWin::IsConnected() const { |
+ if (!completed_handshake()) |
+ return false; |
+ |
+ // Return true if buffered incoming data is not consumed. |
+ if (bytes_received_ || bytes_decrypted_) |
+ return true; |
+ |
// Ideally, we should also check if we have received the close_notify alert |
// message from the server, and return false in that case. We're not doing |
// that, so this function may return a false positive. Since the upper |
// layer (HttpNetworkTransaction) needs to handle a persistent connection |
// closed by the server when we send a request anyway, a false positive in |
// exchange for simpler code is a good trade-off. |
- return completed_handshake() && transport_->socket()->IsConnected(); |
+ return transport_->socket()->IsConnected(); |
} |
bool SSLClientSocketWin::IsConnectedAndIdle() const { |
+ if (!completed_handshake()) |
+ return false; |
+ |
+ // Return false if buffered incoming data is not consumed. |
+ if (bytes_received_ || bytes_decrypted_) |
+ return false; |
+ |
// Unlike IsConnected, this method doesn't return a false positive. |
// |
// Strictly speaking, we should check if we have received the close_notify |
@@ -720,7 +734,7 @@ bool SSLClientSocketWin::IsConnectedAndIdle() const { |
// bytes to the transport layer below, so |
// transport_->socket()->IsConnectedAndIdle() returns the desired false |
// when we receive close_notify. |
- return completed_handshake() && transport_->socket()->IsConnectedAndIdle(); |
+ return transport_->socket()->IsConnectedAndIdle(); |
} |
int SSLClientSocketWin::GetPeerAddress(IPEndPoint* address) const { |