summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-29 16:43:58 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-29 16:43:58 +0000
commitd609f284ee4b5ff4bec43858d411c135ad951285 (patch)
tree349fc2943146581c2ebd797ab2e9e47205861570 /net/http
parent52bb01d16fb6427ddad5c4656c704c4a376e8267 (diff)
downloadchromium_src-d609f284ee4b5ff4bec43858d411c135ad951285.zip
chromium_src-d609f284ee4b5ff4bec43858d411c135ad951285.tar.gz
chromium_src-d609f284ee4b5ff4bec43858d411c135ad951285.tar.bz2
Revert 83524 - Re-connect if Keep-Alive connection has been closed by the time we get around to reusing it. BUG=none TEST=net_unittests --gtest_filter=HttpNetworkTransactionTest.BasicAuthKeepAliveImpatientServer:*.BasicAuthKeepAliveNoBody:*.BasicAuthKeepAliveLargeBody && unit_tests --gtest_filter=*TransportClientSocketTest.IsConnected*Review URL: http://codereview.chromium.org/6878055
TBR=asanka@chromium.org Review URL: http://codereview.chromium.org/6880318 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_basic_stream.cc6
-rw-r--r--net/http/http_basic_stream.h35
-rw-r--r--net/http/http_network_transaction.cc7
-rw-r--r--net/http/http_network_transaction_unittest.cc31
-rw-r--r--net/http/http_response_body_drainer_unittest.cc36
-rw-r--r--net/http/http_stream.h6
-rw-r--r--net/http/http_stream_parser.cc6
-rw-r--r--net/http/http_stream_parser.h4
8 files changed, 41 insertions, 90 deletions
diff --git a/net/http/http_basic_stream.cc b/net/http/http_basic_stream.cc
index 6501a59..ef4d777 100644
--- a/net/http/http_basic_stream.cc
+++ b/net/http/http_basic_stream.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -102,10 +102,6 @@ void HttpBasicStream::SetConnectionReused() {
parser_->SetConnectionReused();
}
-bool HttpBasicStream::IsConnectionReusable() const {
- return parser_->IsConnectionReusable();
-}
-
void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) {
parser_->GetSSLInfo(ssl_info);
}
diff --git a/net/http/http_basic_stream.h b/net/http/http_basic_stream.h
index 267c7c1..2c26315 100644
--- a/net/http/http_basic_stream.h
+++ b/net/http/http_basic_stream.h
@@ -42,44 +42,41 @@ class HttpBasicStream : public HttpStream {
// HttpStream methods:
virtual int InitializeStream(const HttpRequestInfo* request_info,
const BoundNetLog& net_log,
- CompletionCallback* callback) OVERRIDE;
+ CompletionCallback* callback);
virtual int SendRequest(const HttpRequestHeaders& headers,
UploadDataStream* request_body,
HttpResponseInfo* response,
- CompletionCallback* callback) OVERRIDE;
+ CompletionCallback* callback);
- virtual uint64 GetUploadProgress() const OVERRIDE;
+ virtual uint64 GetUploadProgress() const;
- virtual int ReadResponseHeaders(CompletionCallback* callback) OVERRIDE;
+ virtual int ReadResponseHeaders(CompletionCallback* callback);
- virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
+ virtual const HttpResponseInfo* GetResponseInfo() const;
virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
- CompletionCallback* callback) OVERRIDE;
+ CompletionCallback* callback);
- virtual void Close(bool not_reusable) OVERRIDE;
+ virtual void Close(bool not_reusable);
- virtual HttpStream* RenewStreamForAuth() OVERRIDE;
+ virtual HttpStream* RenewStreamForAuth();
- virtual bool IsResponseBodyComplete() const OVERRIDE;
+ virtual bool IsResponseBodyComplete() const;
- virtual bool CanFindEndOfResponse() const OVERRIDE;
+ virtual bool CanFindEndOfResponse() const;
- virtual bool IsMoreDataBuffered() const OVERRIDE;
+ virtual bool IsMoreDataBuffered() const;
- virtual bool IsConnectionReused() const OVERRIDE;
+ virtual bool IsConnectionReused() const;
- virtual void SetConnectionReused() OVERRIDE;
+ virtual void SetConnectionReused();
- virtual bool IsConnectionReusable() const OVERRIDE;
+ virtual void GetSSLInfo(SSLInfo* ssl_info);
- virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
+ virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info);
- virtual void GetSSLCertRequestInfo(
- SSLCertRequestInfo* cert_request_info) OVERRIDE;
-
- virtual bool IsSpdyHttpStream() const OVERRIDE;
+ virtual bool IsSpdyHttpStream() const;
private:
scoped_refptr<GrowableIOBuffer> read_buf_;
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 5cd2f92..46858e6 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -273,7 +273,7 @@ void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
if (stream_.get()) {
HttpStream* new_stream = NULL;
- if (keep_alive && stream_->IsConnectionReusable()) {
+ if (keep_alive) {
// We should call connection_->set_idle_time(), but this doesn't occur
// often enough to be worth the trouble.
stream_->SetConnectionReused();
@@ -281,10 +281,7 @@ void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
}
if (!new_stream) {
- // Close the stream and mark it as not_reusable. Even in the
- // keep_alive case, we've determined that the stream_ is not
- // reusable if new_stream is NULL.
- stream_->Close(true);
+ stream_->Close(!keep_alive);
next_state_ = STATE_CREATE_STREAM;
} else {
next_state_ = STATE_INIT_STREAM;
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index e11860c..64d53ba 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -1192,18 +1192,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
MockRead("Hello"),
};
- // If there is a regression where we disconnect a Keep-Alive
- // connection during an auth roundtrip, we'll end up reading this.
- MockRead data_reads2[] = {
- MockRead(false, ERR_FAILED),
- };
-
StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1),
data_writes1, arraysize(data_writes1));
- StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2),
- NULL, 0);
session_deps.socket_factory.AddSocketDataProvider(&data1);
- session_deps.socket_factory.AddSocketDataProvider(&data2);
TestCompletionCallback callback1;
@@ -1233,7 +1224,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
EXPECT_EQ(OK, rv);
response = trans->GetResponseInfo();
- ASSERT_FALSE(response == NULL);
+ EXPECT_FALSE(response == NULL);
EXPECT_TRUE(response->auth_challenge.get() == NULL);
EXPECT_EQ(5, response->headers->GetContentLength());
}
@@ -1274,17 +1265,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
MockRead("hello"),
};
- // An incorrect reconnect would cause this to be read.
- MockRead data_reads2[] = {
- MockRead(false, ERR_FAILED),
- };
-
StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1),
data_writes1, arraysize(data_writes1));
- StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2),
- NULL, 0);
session_deps.socket_factory.AddSocketDataProvider(&data1);
- session_deps.socket_factory.AddSocketDataProvider(&data2);
TestCompletionCallback callback1;
@@ -1314,7 +1297,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveNoBody) {
EXPECT_EQ(OK, rv);
response = trans->GetResponseInfo();
- ASSERT_FALSE(response == NULL);
+ EXPECT_FALSE(response == NULL);
EXPECT_TRUE(response->auth_challenge.get() == NULL);
EXPECT_EQ(5, response->headers->GetContentLength());
}
@@ -1363,17 +1346,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) {
MockRead("hello"),
};
- // An incorrect reconnect would cause this to be read.
- MockRead data_reads2[] = {
- MockRead(false, ERR_FAILED),
- };
-
StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1),
data_writes1, arraysize(data_writes1));
- StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2),
- NULL, 0);
session_deps.socket_factory.AddSocketDataProvider(&data1);
- session_deps.socket_factory.AddSocketDataProvider(&data2);
TestCompletionCallback callback1;
@@ -1403,7 +1378,7 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAliveLargeBody) {
EXPECT_EQ(OK, rv);
response = trans->GetResponseInfo();
- ASSERT_FALSE(response == NULL);
+ EXPECT_FALSE(response == NULL);
EXPECT_TRUE(response->auth_challenge.get() == NULL);
EXPECT_EQ(5, response->headers->GetContentLength());
}
diff --git a/net/http/http_response_body_drainer_unittest.cc b/net/http/http_response_body_drainer_unittest.cc
index 45c826e..9feed17 100644
--- a/net/http/http_response_body_drainer_unittest.cc
+++ b/net/http/http_response_body_drainer_unittest.cc
@@ -74,48 +74,44 @@ class MockHttpStream : public HttpStream {
// HttpStream implementation:
virtual int InitializeStream(const HttpRequestInfo* request_info,
const BoundNetLog& net_log,
- CompletionCallback* callback) OVERRIDE {
+ CompletionCallback* callback) {
return ERR_UNEXPECTED;
}
virtual int SendRequest(const HttpRequestHeaders& request_headers,
UploadDataStream* request_body,
HttpResponseInfo* response,
- CompletionCallback* callback) OVERRIDE {
+ CompletionCallback* callback) {
return ERR_UNEXPECTED;
}
- virtual uint64 GetUploadProgress() const OVERRIDE { return 0; }
- virtual int ReadResponseHeaders(CompletionCallback* callback) OVERRIDE {
+ virtual uint64 GetUploadProgress() const { return 0; }
+ virtual int ReadResponseHeaders(CompletionCallback* callback) {
return ERR_UNEXPECTED;
}
- virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE {
- return NULL;
- }
+ virtual const HttpResponseInfo* GetResponseInfo() const { return NULL; }
- virtual bool CanFindEndOfResponse() const OVERRIDE { return true; }
- virtual bool IsMoreDataBuffered() const OVERRIDE { return false; }
- virtual bool IsConnectionReused() const OVERRIDE { return false; }
- virtual void SetConnectionReused() OVERRIDE {}
- virtual bool IsConnectionReusable() const OVERRIDE { return false; }
- virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {}
- virtual void GetSSLCertRequestInfo(
- SSLCertRequestInfo* cert_request_info) OVERRIDE {}
+ virtual bool CanFindEndOfResponse() const { return true; }
+ virtual bool IsMoreDataBuffered() const { return false; }
+ virtual bool IsConnectionReused() const { return false; }
+ virtual void SetConnectionReused() {}
+ virtual void GetSSLInfo(SSLInfo* ssl_info) {}
+ virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) {}
// Mocked API
virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
- CompletionCallback* callback) OVERRIDE;
- virtual void Close(bool not_reusable) OVERRIDE {
+ CompletionCallback* callback);
+ virtual void Close(bool not_reusable) {
DCHECK(!closed_);
closed_ = true;
result_waiter_->set_result(not_reusable);
}
- virtual HttpStream* RenewStreamForAuth() OVERRIDE {
+ virtual HttpStream* RenewStreamForAuth() {
return NULL;
}
- virtual bool IsResponseBodyComplete() const OVERRIDE { return is_complete_; }
+ virtual bool IsResponseBodyComplete() const { return is_complete_; }
- virtual bool IsSpdyHttpStream() const OVERRIDE { return false; }
+ virtual bool IsSpdyHttpStream() const { return false; }
// Methods to tweak/observer mock behavior:
void StallReadsForever() { stall_reads_forever_ = true; }
diff --git a/net/http/http_stream.h b/net/http/http_stream.h
index fed64655..e262038 100644
--- a/net/http/http_stream.h
+++ b/net/http/http_stream.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -116,10 +116,6 @@ class HttpStream {
virtual bool IsConnectionReused() const = 0;
virtual void SetConnectionReused() = 0;
- // Checks whether the current state of the underlying connection
- // allows it to be reused.
- virtual bool IsConnectionReusable() const = 0;
-
// Get the SSLInfo associated with this stream's connection. This should
// only be called for streams over SSL sockets, otherwise the behavior is
// undefined.
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 0649bce..eb1ed35 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -700,10 +700,6 @@ void HttpStreamParser::SetConnectionReused() {
connection_->set_is_reused(true);
}
-bool HttpStreamParser::IsConnectionReusable() const {
- return connection_->socket() && connection_->socket()->IsConnectedAndIdle();
-}
-
void HttpStreamParser::GetSSLInfo(SSLInfo* ssl_info) {
if (request_->url.SchemeIs("https") && connection_->socket()) {
SSLClientSocket* ssl_socket =
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index 2192eff..d9241a6 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -67,8 +67,6 @@ class HttpStreamParser : public ChunkCallback {
void SetConnectionReused();
- bool IsConnectionReusable() const;
-
void GetSSLInfo(SSLInfo* ssl_info);
void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info);