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

Unified Diff: net/http/http_response_body_drainer_unittest.cc

Issue 1884943003: HttpStreamParser: Don't reuse sockets which receive unparsed data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 4 years, 7 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 | « net/http/http_response_body_drainer.cc ('k') | net/http/http_stream_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_response_body_drainer_unittest.cc
diff --git a/net/http/http_response_body_drainer_unittest.cc b/net/http/http_response_body_drainer_unittest.cc
index 5cc7f343f7c308ebee37623badf42e7c430d0433..4d280d3038bb88195330f829044aad9560a0400f 100644
--- a/net/http/http_response_body_drainer_unittest.cc
+++ b/net/http/http_response_body_drainer_unittest.cc
@@ -79,6 +79,7 @@ class MockHttpStream : public HttpStream {
is_sync_(false),
is_last_chunk_zero_size_(false),
is_complete_(false),
+ can_reuse_connection_(true),
weak_factory_(this) {}
~MockHttpStream() override {}
@@ -101,7 +102,7 @@ class MockHttpStream : public HttpStream {
bool IsConnectionReused() const override { return false; }
void SetConnectionReused() override {}
- bool CanReuseConnection() const override { return false; }
+ bool CanReuseConnection() const override { return can_reuse_connection_; }
int64_t GetTotalReceivedBytes() const override { return 0; }
int64_t GetTotalSentBytes() const override { return 0; }
void GetSSLInfo(SSLInfo* ssl_info) override {}
@@ -146,6 +147,11 @@ class MockHttpStream : public HttpStream {
void set_is_last_chunk_zero_size() { is_last_chunk_zero_size_ = true; }
+ // Sets result value of CanReuseConnection. Defaults to true.
+ void set_can_reuse_connection(bool can_reuse_connection) {
+ can_reuse_connection_ = can_reuse_connection;
+ }
+
private:
int ReadResponseBodyImpl(IOBuffer* buf, int buf_len);
void CompleteRead();
@@ -162,7 +168,11 @@ class MockHttpStream : public HttpStream {
bool is_sync_;
bool is_last_chunk_zero_size_;
bool is_complete_;
+ bool can_reuse_connection_;
+
base::WeakPtrFactory<MockHttpStream> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockHttpStream);
};
int MockHttpStream::ReadResponseBody(IOBuffer* buf,
@@ -315,6 +325,13 @@ TEST_F(HttpResponseBodyDrainerTest, DrainBodyTooLarge) {
EXPECT_TRUE(result_waiter_.WaitForResult());
}
+TEST_F(HttpResponseBodyDrainerTest, DrainBodyCantReuse) {
+ mock_stream_->set_num_chunks(1);
+ mock_stream_->set_can_reuse_connection(false);
+ drainer_->Start(session_.get());
+ EXPECT_TRUE(result_waiter_.WaitForResult());
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/http/http_response_body_drainer.cc ('k') | net/http/http_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698