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

Side by Side Diff: net/spdy/spdy_test_util_common.cc

Issue 710713002: Remove SPDY2 and SPDY/3.0 from tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/spdy/spdy_test_util_common.h" 5 #include "net/spdy/spdy_test_util_common.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 host->append(":"); 47 host->append(":");
48 host->append(gurl.port()); 48 host->append(gurl.port());
49 } 49 }
50 } 50 }
51 51
52 } // namespace 52 } // namespace
53 53
54 NextProtoVector SpdyNextProtos() { 54 NextProtoVector SpdyNextProtos() {
55 NextProtoVector next_protos; 55 NextProtoVector next_protos;
56 next_protos.push_back(kProtoHTTP11); 56 next_protos.push_back(kProtoHTTP11);
57 next_protos.push_back(kProtoDeprecatedSPDY2);
58 next_protos.push_back(kProtoSPDY3);
59 next_protos.push_back(kProtoSPDY31); 57 next_protos.push_back(kProtoSPDY31);
60 next_protos.push_back(kProtoSPDY4); 58 next_protos.push_back(kProtoSPDY4);
61 next_protos.push_back(kProtoQUIC1SPDY3); 59 next_protos.push_back(kProtoQUIC1SPDY3);
62 return next_protos; 60 return next_protos;
63 } 61 }
64 62
65 // Chop a frame into an array of MockWrites. 63 // Chop a frame into an array of MockWrites.
66 // |data| is the frame to chop. 64 // |data| is the frame to chop.
67 // |length| is the length of the frame to chop. 65 // |length| is the length of the frame to chop.
68 // |num_chunks| is the number of chunks to create. 66 // |num_chunks| is the number of chunks to create.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 } 707 }
710 708
711 SpdyTestUtil::SpdyTestUtil(NextProto protocol) 709 SpdyTestUtil::SpdyTestUtil(NextProto protocol)
712 : protocol_(protocol), 710 : protocol_(protocol),
713 spdy_version_(NextProtoToSpdyMajorVersion(protocol)) { 711 spdy_version_(NextProtoToSpdyMajorVersion(protocol)) {
714 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; 712 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
715 } 713 }
716 714
717 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url, 715 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url,
718 SpdyHeaderBlock* headers) const { 716 SpdyHeaderBlock* headers) const {
719 if (is_spdy2()) { 717 std::string scheme, host, path;
720 (*headers)["url"] = url.as_string(); 718 ParseUrl(url, &scheme, &host, &path);
721 } else { 719 (*headers)[GetSchemeKey()] = scheme;
722 std::string scheme, host, path; 720 (*headers)[GetHostKey()] = host;
723 ParseUrl(url, &scheme, &host, &path); 721 (*headers)[GetPathKey()] = path;
724 (*headers)[GetSchemeKey()] = scheme;
725 (*headers)[GetHostKey()] = host;
726 (*headers)[GetPathKey()] = path;
727 }
728 } 722 }
729 723
730 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlock( 724 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlock(
731 base::StringPiece url) const { 725 base::StringPiece url) const {
732 return ConstructHeaderBlock("GET", url, NULL); 726 return ConstructHeaderBlock("GET", url, NULL);
733 } 727 }
734 728
735 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlockForProxy( 729 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlockForProxy(
736 base::StringPiece url) const { 730 base::StringPiece url) const {
737 scoped_ptr<SpdyHeaderBlock> headers(ConstructGetHeaderBlock(url)); 731 scoped_ptr<SpdyHeaderBlock> headers(ConstructGetHeaderBlock(url));
738 if (is_spdy2())
739 (*headers)[GetPathKey()] = url.data();
740 return headers.Pass(); 732 return headers.Pass();
741 } 733 }
742 734
743 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructHeadHeaderBlock( 735 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructHeadHeaderBlock(
744 base::StringPiece url, 736 base::StringPiece url,
745 int64 content_length) const { 737 int64 content_length) const {
746 return ConstructHeaderBlock("HEAD", url, &content_length); 738 return ConstructHeaderBlock("HEAD", url, &content_length);
747 } 739 }
748 740
749 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructPostHeaderBlock( 741 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructPostHeaderBlock(
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 943 }
952 944
953 SpdyFrame* SpdyTestUtil::ConstructSpdyGet(const char* const extra_headers[], 945 SpdyFrame* SpdyTestUtil::ConstructSpdyGet(const char* const extra_headers[],
954 int extra_header_count, 946 int extra_header_count,
955 bool compressed, 947 bool compressed,
956 int stream_id, 948 int stream_id,
957 RequestPriority request_priority, 949 RequestPriority request_priority,
958 bool direct) const { 950 bool direct) const {
959 SpdyHeaderBlock block; 951 SpdyHeaderBlock block;
960 block[GetMethodKey()] = "GET"; 952 block[GetMethodKey()] = "GET";
961 block[GetPathKey()] = 953 block[GetPathKey()] = "/";
962 (is_spdy2() && !direct) ? "http://www.google.com/" : "/";
963 block[GetHostKey()] = "www.google.com"; 954 block[GetHostKey()] = "www.google.com";
964 block[GetSchemeKey()] = "http"; 955 block[GetSchemeKey()] = "http";
965 MaybeAddVersionHeader(&block); 956 MaybeAddVersionHeader(&block);
966 AppendToHeaderBlock(extra_headers, extra_header_count, &block); 957 AppendToHeaderBlock(extra_headers, extra_header_count, &block);
967 return ConstructSpdySyn(stream_id, block, request_priority, compressed, true); 958 return ConstructSpdySyn(stream_id, block, request_priority, compressed, true);
968 } 959 }
969 960
970 SpdyFrame* SpdyTestUtil::ConstructSpdyConnect( 961 SpdyFrame* SpdyTestUtil::ConstructSpdyConnect(
971 const char* const extra_headers[], 962 const char* const extra_headers[],
972 int extra_header_count, 963 int extra_header_count,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 return kHeader; 1238 return kHeader;
1248 } 1239 }
1249 1240
1250 scoped_ptr<SpdyFramer> SpdyTestUtil::CreateFramer(bool compressed) const { 1241 scoped_ptr<SpdyFramer> SpdyTestUtil::CreateFramer(bool compressed) const {
1251 scoped_ptr<SpdyFramer> framer(new SpdyFramer(spdy_version_)); 1242 scoped_ptr<SpdyFramer> framer(new SpdyFramer(spdy_version_));
1252 framer->set_enable_compression(compressed); 1243 framer->set_enable_compression(compressed);
1253 return framer.Pass(); 1244 return framer.Pass();
1254 } 1245 }
1255 1246
1256 const char* SpdyTestUtil::GetMethodKey() const { 1247 const char* SpdyTestUtil::GetMethodKey() const {
1257 return is_spdy2() ? "method" : ":method"; 1248 return ":method";
1258 } 1249 }
1259 1250
1260 const char* SpdyTestUtil::GetStatusKey() const { 1251 const char* SpdyTestUtil::GetStatusKey() const {
1261 return is_spdy2() ? "status" : ":status"; 1252 return ":status";
1262 } 1253 }
1263 1254
1264 const char* SpdyTestUtil::GetHostKey() const { 1255 const char* SpdyTestUtil::GetHostKey() const {
1265 if (protocol_ < kProtoSPDY3)
1266 return "host";
1267 if (protocol_ < kProtoSPDY4) 1256 if (protocol_ < kProtoSPDY4)
1268 return ":host"; 1257 return ":host";
1269 else 1258 else
1270 return ":authority"; 1259 return ":authority";
1271 } 1260 }
1272 1261
1273 const char* SpdyTestUtil::GetSchemeKey() const { 1262 const char* SpdyTestUtil::GetSchemeKey() const {
1274 return is_spdy2() ? "scheme" : ":scheme"; 1263 return ":scheme";
1275 } 1264 }
1276 1265
1277 const char* SpdyTestUtil::GetVersionKey() const { 1266 const char* SpdyTestUtil::GetVersionKey() const {
1278 return is_spdy2() ? "version" : ":version"; 1267 return ":version";
1279 } 1268 }
1280 1269
1281 const char* SpdyTestUtil::GetPathKey() const { 1270 const char* SpdyTestUtil::GetPathKey() const {
1282 return is_spdy2() ? "url" : ":path"; 1271 return ":path";
1283 } 1272 }
1284 1273
1285 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructHeaderBlock( 1274 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructHeaderBlock(
1286 base::StringPiece method, 1275 base::StringPiece method,
1287 base::StringPiece url, 1276 base::StringPiece url,
1288 int64* content_length) const { 1277 int64* content_length) const {
1289 std::string scheme, host, path; 1278 std::string scheme, host, path;
1290 ParseUrl(url.data(), &scheme, &host, &path); 1279 ParseUrl(url.data(), &scheme, &host, &path);
1291 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock()); 1280 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock());
1292 (*headers)[GetMethodKey()] = method.as_string(); 1281 (*headers)[GetMethodKey()] = method.as_string();
(...skipping 23 matching lines...) Expand all
1316 } 1305 }
1317 } 1306 }
1318 1307
1319 void SpdyTestUtil::SetPriority(RequestPriority priority, 1308 void SpdyTestUtil::SetPriority(RequestPriority priority,
1320 SpdySynStreamIR* ir) const { 1309 SpdySynStreamIR* ir) const {
1321 ir->set_priority(ConvertRequestPriorityToSpdyPriority( 1310 ir->set_priority(ConvertRequestPriorityToSpdyPriority(
1322 priority, spdy_version())); 1311 priority, spdy_version()));
1323 } 1312 }
1324 1313
1325 } // namespace net 1314 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698