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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 275953002: Remove HTTP pipelining support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 arraysize(data_reads)); 738 arraysize(data_reads));
739 EXPECT_EQ(OK, out.rv); 739 EXPECT_EQ(OK, out.rv);
740 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line); 740 EXPECT_EQ("HTTP/1.1 204 No Content", out.status_line);
741 EXPECT_EQ("", out.response_data); 741 EXPECT_EQ("", out.response_data);
742 int64 reads_size = ReadsSize(data_reads, arraysize(data_reads)); 742 int64 reads_size = ReadsSize(data_reads, arraysize(data_reads));
743 int64 response_size = reads_size - strlen(junk); 743 int64 response_size = reads_size - strlen(junk);
744 EXPECT_EQ(response_size, out.totalReceivedBytes); 744 EXPECT_EQ(response_size, out.totalReceivedBytes);
745 } 745 }
746 746
747 // A simple request using chunked encoding with some extra data after. 747 // A simple request using chunked encoding with some extra data after.
748 // (Like might be seen in a pipelined response.)
749 TEST_P(HttpNetworkTransactionTest, ChunkedEncoding) { 748 TEST_P(HttpNetworkTransactionTest, ChunkedEncoding) {
750 std::string final_chunk = "0\r\n\r\n"; 749 std::string final_chunk = "0\r\n\r\n";
751 std::string extra_data = "HTTP/1.1 200 OK\r\n"; 750 std::string extra_data = "HTTP/1.1 200 OK\r\n";
752 std::string last_read = final_chunk + extra_data; 751 std::string last_read = final_chunk + extra_data;
753 MockRead data_reads[] = { 752 MockRead data_reads[] = {
754 MockRead("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"), 753 MockRead("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"),
755 MockRead("5\r\nHello\r\n"), 754 MockRead("5\r\nHello\r\n"),
756 MockRead("1\r\n"), 755 MockRead("1\r\n"),
757 MockRead(" \r\n"), 756 MockRead(" \r\n"),
758 MockRead("5\r\nworld\r\n"), 757 MockRead("5\r\nworld\r\n"),
(...skipping 10419 matching lines...) Expand 10 before | Expand all | Expand 10 after
11178 ASSERT_TRUE(response->headers.get() != NULL); 11177 ASSERT_TRUE(response->headers.get() != NULL);
11179 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 11178 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
11180 EXPECT_TRUE(response->was_fetched_via_spdy); 11179 EXPECT_TRUE(response->was_fetched_via_spdy);
11181 EXPECT_TRUE(response->was_npn_negotiated); 11180 EXPECT_TRUE(response->was_npn_negotiated);
11182 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); 11181 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
11183 EXPECT_EQ("hello!", response_data); 11182 EXPECT_EQ("hello!", response_data);
11184 #endif 11183 #endif
11185 } 11184 }
11186 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration 11185 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration
11187 11186
11188 TEST_P(HttpNetworkTransactionTest, ReadPipelineEvictionFallback) {
11189 MockRead data_reads1[] = {
11190 MockRead(SYNCHRONOUS, ERR_PIPELINE_EVICTION),
11191 };
11192 MockRead data_reads2[] = {
11193 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
11194 MockRead("hello world"),
11195 MockRead(SYNCHRONOUS, OK),
11196 };
11197 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), NULL, 0);
11198 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), NULL, 0);
11199 StaticSocketDataProvider* data[] = { &data1, &data2 };
11200
11201 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data));
11202
11203 EXPECT_EQ(OK, out.rv);
11204 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
11205 EXPECT_EQ("hello world", out.response_data);
11206 }
11207
11208 TEST_P(HttpNetworkTransactionTest, SendPipelineEvictionFallback) {
11209 MockWrite data_writes1[] = {
11210 MockWrite(SYNCHRONOUS, ERR_PIPELINE_EVICTION),
11211 };
11212 MockWrite data_writes2[] = {
11213 MockWrite("GET / HTTP/1.1\r\n"
11214 "Host: www.google.com\r\n"
11215 "Connection: keep-alive\r\n\r\n"),
11216 };
11217 MockRead data_reads2[] = {
11218 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
11219 MockRead("hello world"),
11220 MockRead(SYNCHRONOUS, OK),
11221 };
11222 StaticSocketDataProvider data1(NULL, 0,
11223 data_writes1, arraysize(data_writes1));
11224 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2),
11225 data_writes2, arraysize(data_writes2));
11226 StaticSocketDataProvider* data[] = { &data1, &data2 };
11227
11228 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data));
11229
11230 EXPECT_EQ(OK, out.rv);
11231 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
11232 EXPECT_EQ("hello world", out.response_data);
11233 }
11234
11235 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { 11187 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) {
11236 const std::string https_url = "https://www.google.com/"; 11188 const std::string https_url = "https://www.google.com/";
11237 const std::string http_url = "http://www.google.com:443/"; 11189 const std::string http_url = "http://www.google.com:443/";
11238 11190
11239 // SPDY GET for HTTPS URL 11191 // SPDY GET for HTTPS URL
11240 scoped_ptr<SpdyFrame> req1( 11192 scoped_ptr<SpdyFrame> req1(
11241 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); 11193 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST));
11242 11194
11243 MockWrite writes1[] = { 11195 MockWrite writes1[] = {
11244 CreateMockWrite(*req1, 0), 11196 CreateMockWrite(*req1, 0),
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
12336 } 12288 }
12337 12289
12338 virtual void PreconnectStreams(int num_streams, 12290 virtual void PreconnectStreams(int num_streams,
12339 const HttpRequestInfo& info, 12291 const HttpRequestInfo& info,
12340 RequestPriority priority, 12292 RequestPriority priority,
12341 const SSLConfig& server_ssl_config, 12293 const SSLConfig& server_ssl_config,
12342 const SSLConfig& proxy_ssl_config) OVERRIDE { 12294 const SSLConfig& proxy_ssl_config) OVERRIDE {
12343 ADD_FAILURE(); 12295 ADD_FAILURE();
12344 } 12296 }
12345 12297
12346 virtual base::Value* PipelineInfoToValue() const OVERRIDE {
12347 ADD_FAILURE();
12348 return NULL;
12349 }
12350
12351 virtual const HostMappingRules* GetHostMappingRules() const OVERRIDE { 12298 virtual const HostMappingRules* GetHostMappingRules() const OVERRIDE {
12352 ADD_FAILURE(); 12299 ADD_FAILURE();
12353 return NULL; 12300 return NULL;
12354 } 12301 }
12355 12302
12356 private: 12303 private:
12357 base::WeakPtr<FakeStreamRequest> last_stream_request_; 12304 base::WeakPtr<FakeStreamRequest> last_stream_request_;
12358 12305
12359 DISALLOW_COPY_AND_ASSIGN(FakeStreamFactory); 12306 DISALLOW_COPY_AND_ASSIGN(FakeStreamFactory);
12360 }; 12307 };
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
13136 EXPECT_EQ(ERR_IO_PENDING, rv); 13083 EXPECT_EQ(ERR_IO_PENDING, rv);
13137 13084
13138 rv = callback.WaitForResult(); 13085 rv = callback.WaitForResult();
13139 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 13086 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
13140 13087
13141 const HttpResponseInfo* response = trans->GetResponseInfo(); 13088 const HttpResponseInfo* response = trans->GetResponseInfo();
13142 EXPECT_TRUE(response == NULL); 13089 EXPECT_TRUE(response == NULL);
13143 } 13090 }
13144 13091
13145 } // namespace net 13092 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698