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

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

Issue 17760008: [SPDY] Enable tests for SPDY/3.1 and SPDY/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 5 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
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/spdy/spdy_websocket_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "net/cert/mock_cert_verifier.h" 13 #include "net/cert/mock_cert_verifier.h"
14 #include "net/http/http_cache.h" 14 #include "net/http/http_cache.h"
15 #include "net/http/http_network_session.h" 15 #include "net/http/http_network_session.h"
16 #include "net/http/http_network_transaction.h" 16 #include "net/http/http_network_transaction.h"
17 #include "net/http/http_server_properties_impl.h" 17 #include "net/http/http_server_properties_impl.h"
18 #include "net/socket/socket_test_util.h" 18 #include "net/socket/socket_test_util.h"
19 #include "net/socket/ssl_client_socket.h"
19 #include "net/spdy/buffered_spdy_framer.h" 20 #include "net/spdy/buffered_spdy_framer.h"
20 #include "net/spdy/spdy_framer.h" 21 #include "net/spdy/spdy_framer.h"
21 #include "net/spdy/spdy_http_utils.h" 22 #include "net/spdy/spdy_http_utils.h"
22 #include "net/spdy/spdy_session.h" 23 #include "net/spdy/spdy_session.h"
23 #include "net/spdy/spdy_stream.h" 24 #include "net/spdy/spdy_stream.h"
24 25
25 namespace net { 26 namespace net {
26 27
27 namespace { 28 namespace {
28 29
(...skipping 11 matching lines...) Expand all
40 scheme->assign(gurl.scheme()); 41 scheme->assign(gurl.scheme());
41 host->assign(gurl.host()); 42 host->assign(gurl.host());
42 if (gurl.has_port()) { 43 if (gurl.has_port()) {
43 host->append(":"); 44 host->append(":");
44 host->append(gurl.port()); 45 host->append(gurl.port());
45 } 46 }
46 } 47 }
47 48
48 } // namespace 49 } // namespace
49 50
51 std::vector<std::string> SpdyNextProtos() {
52 std::vector<std::string> next_protos;
53 for (int i = kProtoMinimumVersion; i <= kProtoMaximumVersion; ++i) {
54 next_protos.push_back(SSLClientSocket::NextProtoToString(
55 static_cast<NextProto>(i)));
56 }
57 return next_protos;
58 }
59
50 // Chop a frame into an array of MockWrites. 60 // Chop a frame into an array of MockWrites.
51 // |data| is the frame to chop. 61 // |data| is the frame to chop.
52 // |length| is the length of the frame to chop. 62 // |length| is the length of the frame to chop.
53 // |num_chunks| is the number of chunks to create. 63 // |num_chunks| is the number of chunks to create.
54 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { 64 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) {
55 MockWrite* chunks = new MockWrite[num_chunks]; 65 MockWrite* chunks = new MockWrite[num_chunks];
56 int chunk_size = length / num_chunks; 66 int chunk_size = length / num_chunks;
57 for (int index = 0; index < num_chunks; index++) { 67 for (int index = 0; index < num_chunks; index++) {
58 const char* ptr = data + (index * chunk_size); 68 const char* ptr = data + (index * chunk_size);
59 if (index == num_chunks - 1) 69 if (index == num_chunks - 1)
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 case kProtoSPDY31: 527 case kProtoSPDY31:
518 return SPDY3; 528 return SPDY3;
519 case kProtoSPDY4a2: 529 case kProtoSPDY4a2:
520 return SPDY4; 530 return SPDY4;
521 default: 531 default:
522 NOTREACHED(); 532 NOTREACHED();
523 return SPDY2; 533 return SPDY2;
524 } 534 }
525 } 535 }
526 536
537 AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) {
538 switch (next_proto) {
539 case kProtoSPDY2:
540 return NPN_SPDY_2;
541 case kProtoSPDY3:
542 return NPN_SPDY_3;
543 case kProtoSPDY31:
544 return NPN_SPDY_3_1;
545 case kProtoSPDY4a2:
546 return NPN_SPDY_4A2;
547
548 case kProtoUnknown:
549 case kProtoHTTP11:
550 case kProtoSPDY1:
551 case kProtoSPDY21:
552 break;
553 }
554
555 NOTREACHED();
556 return NPN_SPDY_2;
557 }
558
527 SpdyTestUtil::SpdyTestUtil(NextProto protocol) 559 SpdyTestUtil::SpdyTestUtil(NextProto protocol)
528 : protocol_(protocol), 560 : protocol_(protocol),
529 spdy_version_(SpdyVersionFromNextProto(protocol)) { 561 spdy_version_(SpdyVersionFromNextProto(protocol)) {
530 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; 562 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
531 } 563 }
532 564
533 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url, 565 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url,
534 SpdyHeaderBlock* headers) const { 566 SpdyHeaderBlock* headers) const {
535 if (is_spdy2()) { 567 if (is_spdy2()) {
536 (*headers)["url"] = url.as_string(); 568 (*headers)["url"] = url.as_string();
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 (*headers)[GetSchemeKey()] = scheme.c_str(); 1092 (*headers)[GetSchemeKey()] = scheme.c_str();
1061 (*headers)[GetVersionKey()] = "HTTP/1.1"; 1093 (*headers)[GetVersionKey()] = "HTTP/1.1";
1062 if (content_length) { 1094 if (content_length) {
1063 std::string length_str = base::Int64ToString(*content_length); 1095 std::string length_str = base::Int64ToString(*content_length);
1064 (*headers)["content-length"] = length_str; 1096 (*headers)["content-length"] = length_str;
1065 } 1097 }
1066 return headers.Pass(); 1098 return headers.Pass();
1067 } 1099 }
1068 1100
1069 } // namespace net 1101 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/spdy/spdy_websocket_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698