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

Unified Diff: net/socket/ssl_client_socket_win.cc

Issue 11366155: SSLClientSocket::IsConnected should care for internal buffers (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase to new rev. Created 7 years, 11 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
« net/socket/ssl_client_socket_nss.cc ('K') | « net/socket/ssl_client_socket_nss.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« net/socket/ssl_client_socket_nss.cc ('K') | « net/socket/ssl_client_socket_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698