diff options
author | bnc <bnc@chromium.org> | 2016-01-08 15:48:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 23:49:15 +0000 |
commit | 05808ff4705c00acc1d0a2683a0ed657db4e4abf (patch) | |
tree | 6dc734a7d8f18c273688e2169797c94cc90d08fa /net | |
parent | b5cff0041ec225f4eaac870e87d6189321754983 (diff) | |
download | chromium_src-05808ff4705c00acc1d0a2683a0ed657db4e4abf.zip chromium_src-05808ff4705c00acc1d0a2683a0ed657db4e4abf.tar.gz chromium_src-05808ff4705c00acc1d0a2683a0ed657db4e4abf.tar.bz2 |
Remove SPDY/2 code.
SPDY/2 code path has been unused for a long time, this CL actually removes it.
Note that there have been two comparisons between an enum SpdyMajorVersion value
and an interger literal: one in SpdyFramer::WriteHeaderBlockToZ(), and one in
spdy_http_utils.cc::SpdyHeadersToHttpResponse(). Changing enum SpdyMajorVersion
member values lead to errors. However, removing SPDY/2 made these comparisons
mute (they were both |version < SPDY3|), so they are removed instead of fixed.
This CL lands server change 111503966 by alyssar.
BUG=431299, 488484
Review URL: https://codereview.chromium.org/1561203003
Cr-Commit-Position: refs/heads/master@{#368459}
Diffstat (limited to 'net')
23 files changed, 200 insertions, 1032 deletions
diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc index 4c15210..b97a0c3 100644 --- a/net/http/http_response_info.cc +++ b/net/http/http_response_info.cc @@ -389,8 +389,6 @@ void HttpResponseInfo::Persist(base::Pickle* pickle, HttpResponseInfo::ConnectionInfo HttpResponseInfo::ConnectionInfoFromNextProto( NextProto next_proto) { switch (next_proto) { - case kProtoDeprecatedSPDY2: - return CONNECTION_INFO_DEPRECATED_SPDY2; case kProtoSPDY3: case kProtoSPDY31: return CONNECTION_INFO_SPDY3; @@ -417,7 +415,8 @@ std::string HttpResponseInfo::ConnectionInfoToString( case CONNECTION_INFO_HTTP1: return "http/1"; case CONNECTION_INFO_DEPRECATED_SPDY2: - return "spdy/2"; + NOTREACHED(); + return ""; case CONNECTION_INFO_SPDY3: return "spdy/3"; // Since ConnectionInfo is persisted to disk, deprecated values have to be diff --git a/net/http/http_server_properties.cc b/net/http/http_server_properties.cc index 1a4291b..8b8b50c 100644 --- a/net/http/http_server_properties.cc +++ b/net/http/http_server_properties.cc @@ -20,7 +20,6 @@ namespace { // The order of these strings much match the order of the enum definition // for AlternateProtocol. const char* const kAlternateProtocolStrings[] = { - "npn-spdy/2", "npn-spdy/3", "npn-spdy/3.1", "npn-h2", @@ -50,7 +49,6 @@ bool IsAlternateProtocolValid(AlternateProtocol protocol) { const char* AlternateProtocolToString(AlternateProtocol protocol) { switch (protocol) { - case DEPRECATED_NPN_SPDY_2: case NPN_SPDY_3: case NPN_SPDY_3_1: case NPN_HTTP_2: @@ -77,8 +75,6 @@ AlternateProtocol AlternateProtocolFromString(const std::string& str) { AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) { switch (next_proto) { - case kProtoDeprecatedSPDY2: - return DEPRECATED_NPN_SPDY_2; case kProtoSPDY3: return NPN_SPDY_3; case kProtoSPDY31: diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index 85b7285..9db9fc8 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h @@ -66,12 +66,11 @@ NET_EXPORT void HistogramBrokenAlternateProtocolLocation( BrokenAlternateProtocolLocation location); enum AlternateProtocol { - DEPRECATED_NPN_SPDY_2 = 0, - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION = DEPRECATED_NPN_SPDY_2, - NPN_SPDY_MINIMUM_VERSION = DEPRECATED_NPN_SPDY_2, NPN_SPDY_3, + ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION = NPN_SPDY_3, + NPN_SPDY_MINIMUM_VERSION = NPN_SPDY_3, NPN_SPDY_3_1, - NPN_HTTP_2, // HTTP/2 + NPN_HTTP_2, NPN_SPDY_MAXIMUM_VERSION = NPN_HTTP_2, QUIC, ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION = QUIC, diff --git a/net/socket/next_proto.h b/net/socket/next_proto.h index 06f31ba..20c1a35 100644 --- a/net/socket/next_proto.h +++ b/net/socket/next_proto.h @@ -18,15 +18,14 @@ namespace net { // are used to collect statistics on UMA. Also, values must be in [0,499), // because of the way TLS protocol negotiation extension information is added to // UMA histogram. +const int kProtoSPDYHistogramOffset = 100; enum NextProto { kProtoUnknown = 0, kProtoHTTP11 = 1, kProtoMinimumVersion = kProtoHTTP11, - kProtoDeprecatedSPDY2 = 100, - kProtoSPDYMinimumVersion = kProtoDeprecatedSPDY2, - kProtoSPDYHistogramOffset = kProtoDeprecatedSPDY2, kProtoSPDY3 = 101, + kProtoSPDYMinimumVersion = kProtoSPDY3, kProtoSPDY31 = 102, // kProtoHTTP2_14 = 103, // HTTP/2 draft-14 // kProtoHTTP2_15 = 104, // HTTP/2 draft-15 diff --git a/net/socket/ssl_client_socket.cc b/net/socket/ssl_client_socket.cc index 9b5a0a9..2c9538a 100644 --- a/net/socket/ssl_client_socket.cc +++ b/net/socket/ssl_client_socket.cc @@ -32,8 +32,6 @@ NextProto SSLClientSocket::NextProtoFromString( const std::string& proto_string) { if (proto_string == "http1.1" || proto_string == "http/1.1") { return kProtoHTTP11; - } else if (proto_string == "spdy/2") { - return kProtoDeprecatedSPDY2; } else if (proto_string == "spdy/3") { return kProtoSPDY3; } else if (proto_string == "spdy/3.1") { @@ -52,8 +50,6 @@ const char* SSLClientSocket::NextProtoToString(NextProto next_proto) { switch (next_proto) { case kProtoHTTP11: return "http/1.1"; - case kProtoDeprecatedSPDY2: - return "spdy/2"; case kProtoSPDY3: return "spdy/3"; case kProtoSPDY31: diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc index d136d1d..6c8ad6e 100644 --- a/net/spdy/buffered_spdy_framer.cc +++ b/net/spdy/buffered_spdy_framer.cc @@ -21,8 +21,6 @@ size_t kHeaderBufferMaxSize = 256 * 1024; SpdyMajorVersion NextProtoToSpdyMajorVersion(NextProto next_proto) { switch (next_proto) { - case kProtoDeprecatedSPDY2: - return SPDY2; case kProtoSPDY3: case kProtoSPDY31: return SPDY3; @@ -34,7 +32,7 @@ SpdyMajorVersion NextProtoToSpdyMajorVersion(NextProto next_proto) { break; } NOTREACHED(); - return SPDY2; + return HTTP2; } BufferedSpdyFramer::BufferedSpdyFramer(SpdyMajorVersion version, diff --git a/net/spdy/spdy_frame_builder_test.cc b/net/spdy/spdy_frame_builder_test.cc index e352303..70b9374 100644 --- a/net/spdy/spdy_frame_builder_test.cc +++ b/net/spdy/spdy_frame_builder_test.cc @@ -18,11 +18,10 @@ class SpdyFrameBuilderTest : public ::testing::TestWithParam<SpdyMajorVersion> { SpdyMajorVersion spdy_version_; }; -// All tests are run with three different SPDY versions: SPDY/2, SPDY/3 and -// HTTP/2. +// All tests are run with SPDY/3 and HTTP/2. INSTANTIATE_TEST_CASE_P(SpdyFrameBuilderTests, SpdyFrameBuilderTest, - ::testing::Values(SPDY2, SPDY3, HTTP2)); + ::testing::Values(SPDY3, HTTP2)); TEST_P(SpdyFrameBuilderTest, GetWritableBuffer) { const size_t builder_size = 10; diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 08f32dd..2a2fb4d 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -82,10 +82,8 @@ void UnpackStreamDependencyValues(uint32_t packed, struct DictionaryIds { DictionaryIds() - : v2_dictionary_id(CalculateDictionaryId(kV2Dictionary, kV2DictionarySize)), - v3_dictionary_id(CalculateDictionaryId(kV3Dictionary, kV3DictionarySize)) - {} - const uLong v2_dictionary_id; + : v3_dictionary_id( + CalculateDictionaryId(kV3Dictionary, kV3DictionarySize)) {} const uLong v3_dictionary_id; }; @@ -137,9 +135,6 @@ const size_t SpdyFramer::kControlFrameBufferSize = 19; SettingsFlagsAndId SettingsFlagsAndId::FromWireFormat(SpdyMajorVersion version, uint32_t wire) { - if (version < SPDY3) { - ConvertFlagsAndIdForSpdy2(&wire); - } return SettingsFlagsAndId(base::NetToHost32(wire) >> 24, base::NetToHost32(wire) & 0x00ffffff); } @@ -150,23 +145,7 @@ SettingsFlagsAndId::SettingsFlagsAndId(uint8_t flags, uint32_t id) } uint32_t SettingsFlagsAndId::GetWireFormat(SpdyMajorVersion version) const { - uint32_t wire = - base::HostToNet32(id_ & 0x00ffffff) | base::HostToNet32(flags_ << 24); - if (version < SPDY3) { - ConvertFlagsAndIdForSpdy2(&wire); - } - return wire; -} - -// SPDY 2 had a bug in it with respect to byte ordering of id/flags field. -// This method is used to preserve buggy behavior and works on both -// little-endian and big-endian hosts. -// This method is also bidirectional (can be used to translate SPDY 2 to SPDY 3 -// as well as vice versa). -void SettingsFlagsAndId::ConvertFlagsAndIdForSpdy2(uint32_t* val) { - uint8_t* wire_array = reinterpret_cast<uint8_t*>(val); - std::swap(wire_array[0], wire_array[3]); - std::swap(wire_array[1], wire_array[2]); + return base::HostToNet32(id_ & 0x00ffffff) | base::HostToNet32(flags_ << 24); } bool SpdyFramerVisitorInterface::OnGoAwayFrameData(const char* goaway_data, @@ -258,11 +237,6 @@ size_t SpdyFramer::GetSynReplyMinimumSize() const { size += 4; } - // In SPDY 2, there were 2 unused bytes before payload. - if (protocol_version() < SPDY3) { - size += 2; - } - return size; } @@ -311,10 +285,8 @@ size_t SpdyFramer::GetGoAwayMinimumSize() const { // 2. Last good stream id (4 bytes) size += 4; - // 3. SPDY 3+ GOAWAY frames also contain a status (4 bytes) - if (protocol_version() >= SPDY3) { - size += 4; - } + // 3. GOAWAY frames also contain a status (4 bytes) + size += 4; return size; } @@ -329,11 +301,6 @@ size_t SpdyFramer::GetHeadersMinimumSize() const { size += 4; } - // In SPDY 2, there were 2 unused bytes before payload. - if (protocol_version() <= SPDY2) { - size += 2; - } - return size; } @@ -1198,8 +1165,7 @@ size_t SpdyFramer::UpdateCurrentFrameBuffer(const char** data, size_t* len, size_t SpdyFramer::GetSerializedLength( const SpdyMajorVersion spdy_version, const SpdyHeaderBlock* headers) { - const size_t num_name_value_pairs_size = - (spdy_version < SPDY3) ? sizeof(uint16_t) : sizeof(uint32_t); + const size_t num_name_value_pairs_size = sizeof(uint32_t); const size_t length_of_name_size = num_name_value_pairs_size; const size_t length_of_value_size = num_name_value_pairs_size; @@ -1216,20 +1182,11 @@ size_t SpdyFramer::GetSerializedLength( void SpdyFramer::WriteHeaderBlock(SpdyFrameBuilder* frame, const SpdyMajorVersion spdy_version, const SpdyHeaderBlock* headers) { - if (spdy_version < SPDY3) { - frame->WriteUInt16(static_cast<uint16_t>(headers->size())); - } else { - frame->WriteUInt32(headers->size()); - } + frame->WriteUInt32(headers->size()); SpdyHeaderBlock::const_iterator it; for (it = headers->begin(); it != headers->end(); ++it) { - if (spdy_version < SPDY3) { - frame->WriteStringPiece16(it->first); - frame->WriteStringPiece16(it->second); - } else { - frame->WriteStringPiece32(it->first); - frame->WriteStringPiece32(it->second); - } + frame->WriteStringPiece32(it->first); + frame->WriteStringPiece32(it->second); } } @@ -1307,10 +1264,7 @@ static void WriteLengthZ(size_t n, // cookie data. void SpdyFramer::WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, z_stream* z) const { - unsigned length_length = 4; - if (protocol_version() < 3) - length_length = 2; - + const size_t length_length = 4; WriteLengthZ(headers->size(), length_length, kZStandardData, z); SpdyHeaderBlock::const_iterator it; @@ -1443,11 +1397,7 @@ size_t SpdyFramer::ProcessControlFrameBeforeHeaderBlock(const char* data, SpdyPriority priority = 0; successful_read = reader.ReadUInt8(&priority); DCHECK(successful_read); - if (protocol_version() <= SPDY2) { - priority = priority >> 6; - } else { - priority = priority >> 5; - } + priority = priority >> 5; // Seek past unused byte. reader.Seek(1); @@ -1495,10 +1445,6 @@ size_t SpdyFramer::ProcessControlFrameBeforeHeaderBlock(const char* data, set_error(SPDY_INVALID_CONTROL_FRAME); break; } - if (protocol_version() <= SPDY2) { - // SPDY 2 had two unused bytes here. Seek past them. - reader.Seek(2); - } if (protocol_version() > SPDY3 && !(current_frame_flags_ & HEADERS_FLAG_END_HEADERS) && current_frame_type_ == HEADERS) { @@ -2209,18 +2155,9 @@ bool SpdyFramer::ParseHeaderBlockInBuffer(const char* header_data, // Read number of headers. uint32_t num_headers; - if (protocol_version() <= SPDY2) { - uint16_t temp; - if (!reader.ReadUInt16(&temp)) { - DVLOG(1) << "Unable to read number of headers."; - return false; - } - num_headers = temp; - } else { - if (!reader.ReadUInt32(&num_headers)) { - DVLOG(1) << "Unable to read number of headers."; - return false; - } + if (!reader.ReadUInt32(&num_headers)) { + DVLOG(1) << "Unable to read number of headers."; + return false; } // Read each header. @@ -2228,8 +2165,7 @@ bool SpdyFramer::ParseHeaderBlockInBuffer(const char* header_data, base::StringPiece temp; // Read header name. - if ((protocol_version() <= SPDY2) ? !reader.ReadStringPiece16(&temp) - : !reader.ReadStringPiece32(&temp)) { + if (!reader.ReadStringPiece32(&temp)) { DVLOG(1) << "Unable to read header name (" << index + 1 << " of " << num_headers << ")."; return false; @@ -2237,8 +2173,7 @@ bool SpdyFramer::ParseHeaderBlockInBuffer(const char* header_data, std::string name = temp.as_string(); // Read header value. - if ((protocol_version() <= SPDY2) ? !reader.ReadStringPiece16(&temp) - : !reader.ReadStringPiece32(&temp)) { + if (!reader.ReadStringPiece32(&temp)) { DVLOG(1) << "Unable to read header value (" << index + 1 << " of " << num_headers << ")."; return false; @@ -2363,7 +2298,7 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream( builder.WriteControlFrameHeader(*this, SYN_STREAM, flags); builder.WriteUInt32(syn_stream.stream_id()); builder.WriteUInt32(syn_stream.associated_to_stream_id()); - builder.WriteUInt8(priority << ((protocol_version() <= SPDY2) ? 6 : 5)); + builder.WriteUInt8(priority << 5); builder.WriteUInt8(0); // Unused byte. DCHECK_EQ(GetSynStreamMinimumSize(), builder.length()); SerializeHeaderBlock(&builder, syn_stream); @@ -2402,9 +2337,6 @@ SpdySerializedFrame* SpdyFramer::SerializeSynReply( flags, syn_reply.stream_id()); } - if (protocol_version() < SPDY3) { - builder.WriteUInt16(0); // Unused. - } DCHECK_EQ(GetSynReplyMinimumSize(), builder.length()); SerializeHeaderBlock(&builder, syn_reply); @@ -2544,7 +2476,7 @@ SpdySerializedFrame* SpdyFramer::SerializeGoAway( // GOAWAY frames specify the last good stream id for all SPDY versions. builder.WriteUInt32(goaway.last_good_stream_id()); - // In SPDY3 and up, GOAWAY frames also specify the error status code. + // GOAWAY frames also specify the error status code. if (protocol_version() >= SPDY3) { // TODO(jgraettinger): Merge back to server-side. builder.WriteUInt32(SpdyConstants::SerializeGoAwayStatus(protocol_version(), @@ -2625,9 +2557,6 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders( flags, headers.stream_id()); } - if (protocol_version() <= SPDY2) { - builder.WriteUInt16(0); // Unused. - } DCHECK_EQ(GetHeadersMinimumSize(), builder.length()); if (protocol_version() > SPDY3) { @@ -2990,10 +2919,8 @@ z_stream* SpdyFramer::GetHeaderCompressor() { kCompressorMemLevel, Z_DEFAULT_STRATEGY); if (success == Z_OK) { - const char* dictionary = (protocol_version() <= SPDY2) ? - kV2Dictionary : kV3Dictionary; - const int dictionary_size = (protocol_version() <= SPDY2) ? - kV2DictionarySize : kV3DictionarySize; + const char* dictionary = kV3Dictionary; + const int dictionary_size = kV3DictionarySize; success = deflateSetDictionary(header_compressor_.get(), reinterpret_cast<const Bytef*>(dictionary), dictionary_size); @@ -3080,13 +3007,10 @@ bool SpdyFramer::IncrementallyDecompressControlFrameHeaderData( int rv = inflate(decomp, Z_SYNC_FLUSH); if (rv == Z_NEED_DICT) { - const char* dictionary = (protocol_version() <= SPDY2) ? kV2Dictionary - : kV3Dictionary; - const int dictionary_size = (protocol_version() <= SPDY2) ? - kV2DictionarySize : kV3DictionarySize; + const char* dictionary = kV3Dictionary; + const int dictionary_size = kV3DictionarySize; const DictionaryIds& ids = g_dictionary_ids.Get(); - const uLong dictionary_id = (protocol_version() <= SPDY2) ? - ids.v2_dictionary_id : ids.v3_dictionary_id; + const uLong dictionary_id = ids.v3_dictionary_id; // Need to try again with the right dictionary. if (decomp->adler == dictionary_id) { rv = inflateSetDictionary(decomp, @@ -3157,21 +3081,12 @@ void SpdyFramer::SerializeHeaderBlockWithoutCompression( SpdyFrameBuilder* builder, const SpdyHeaderBlock& header_block) const { // Serialize number of headers. - if (protocol_version() <= SPDY2) { - builder->WriteUInt16(static_cast<uint16_t>(header_block.size())); - } else { - builder->WriteUInt32(header_block.size()); - } + builder->WriteUInt32(header_block.size()); // Serialize each header. for (const auto& header : header_block) { - if (protocol_version() <= SPDY2) { - builder->WriteStringPiece16(header.first); - builder->WriteStringPiece16(header.second); - } else { - builder->WriteStringPiece32(header.first); - builder->WriteStringPiece32(header.second); - } + builder->WriteStringPiece32(header.first); + builder->WriteStringPiece32(header.second); } } diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index 35bfafb..5f3ff2a 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h @@ -64,8 +64,6 @@ class NET_EXPORT_PRIVATE SettingsFlagsAndId { uint8_t flags() const { return flags_; } private: - static void ConvertFlagsAndIdForSpdy2(uint32_t* val); - uint8_t flags_; uint32_t id_; }; @@ -548,9 +546,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { bool probable_http_response() const { return probable_http_response_; } - SpdyPriority GetLowestPriority() const { - return protocol_version_ < SPDY3 ? 3 : 7; - } + SpdyPriority GetLowestPriority() const { return 7; } SpdyPriority GetHighestPriority() const { return 0; } diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 3c56be9..ac97137 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -680,7 +680,6 @@ class SpdyFramerTest : public ::testing::TestWithParam<SpdyMajorVersion> { actual_frame.size()); } - bool IsSpdy2() { return spdy_version_ == SPDY2; } bool IsSpdy3() { return spdy_version_ == SPDY3; } bool IsHttp2() { return spdy_version_ == HTTP2; } @@ -689,10 +688,10 @@ class SpdyFramerTest : public ::testing::TestWithParam<SpdyMajorVersion> { unsigned char spdy_version_ch_; }; -// All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, HTTP/2. +// All tests are run with SPDY/3 and HTTP/2. INSTANTIATE_TEST_CASE_P(SpdyFramerTests, SpdyFramerTest, - ::testing::Values(SPDY2, SPDY3, HTTP2)); + ::testing::Values(SPDY3, HTTP2)); // Test that we ignore cookie where both name and value are empty. TEST_P(SpdyFramerTest, HeaderBlockWithEmptyCookie) { @@ -914,19 +913,11 @@ TEST_P(SpdyFramerTest, DuplicateHeader) { frame.WriteUInt32(framer.GetHighestPriority()); } - if (IsSpdy2()) { - frame.WriteUInt16(2); // Number of headers. - frame.WriteStringPiece16("name"); - frame.WriteStringPiece16("value1"); - frame.WriteStringPiece16("name"); - frame.WriteStringPiece16("value2"); - } else { - frame.WriteUInt32(2); // Number of headers. - frame.WriteStringPiece32("name"); - frame.WriteStringPiece32("value1"); - frame.WriteStringPiece32("name"); - frame.WriteStringPiece32("value2"); - } + frame.WriteUInt32(2); // Number of headers. + frame.WriteStringPiece32("name"); + frame.WriteStringPiece32("value1"); + frame.WriteStringPiece32("name"); + frame.WriteStringPiece32("value2"); // write the length frame.RewriteLength(framer); @@ -960,11 +951,7 @@ TEST_P(SpdyFramerTest, MultiValueHeader) { } string value("value1\0value2", 13); - if (IsSpdy2()) { - frame.WriteUInt16(1); // Number of headers. - frame.WriteStringPiece16("name"); - frame.WriteStringPiece16(value); - } else if (spdy_version_ > SPDY3) { + if (spdy_version_ > SPDY3) { // TODO(jgraettinger): If this pattern appears again, move to test class. SpdyHeaderBlock header_set; header_set["name"] = value; @@ -1013,21 +1000,12 @@ TEST_P(SpdyFramerTest, BasicCompression) { size_t uncompressed_size1 = visitor->last_payload_len_; size_t compressed_size1 = visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); - if (IsSpdy2()) { - EXPECT_EQ(139u, uncompressed_size1); -#if defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(155u, compressed_size1); -#else // !defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(135u, compressed_size1); -#endif // !defined(USE_SYSTEM_ZLIB) - } else { - EXPECT_EQ(165u, uncompressed_size1); + EXPECT_EQ(165u, uncompressed_size1); #if defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(181u, compressed_size1); + EXPECT_EQ(181u, compressed_size1); #else // !defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(117u, compressed_size1); + EXPECT_EQ(117u, compressed_size1); #endif // !defined(USE_SYSTEM_ZLIB) - } scoped_ptr<SpdyFrame> frame2(framer.SerializeSynStream(syn_stream)); size_t uncompressed_size2 = visitor->last_payload_len_; size_t compressed_size2 = @@ -1049,21 +1027,12 @@ TEST_P(SpdyFramerTest, BasicCompression) { frame4->size() - framer.GetSynStreamMinimumSize(); size_t compressed_size4 = visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); - if (IsSpdy2()) { - EXPECT_EQ(139u, uncompressed_size4); -#if defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(149u, compressed_size4); -#else // !defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(99u, compressed_size4); -#endif // !defined(USE_SYSTEM_ZLIB) - } else { - EXPECT_EQ(165u, uncompressed_size4); + EXPECT_EQ(165u, uncompressed_size4); #if defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(175u, compressed_size4); + EXPECT_EQ(175u, compressed_size4); #else // !defined(USE_SYSTEM_ZLIB) - EXPECT_EQ(99u, compressed_size4); + EXPECT_EQ(99u, compressed_size4); #endif // !defined(USE_SYSTEM_ZLIB) - } EXPECT_EQ(uncompressed_size1, uncompressed_size2); EXPECT_EQ(uncompressed_size1, uncompressed_size4); @@ -1097,59 +1066,6 @@ TEST_P(SpdyFramerTest, CompressEmptyHeaders) { } TEST_P(SpdyFramerTest, Basic) { - const unsigned char kV2Input[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 - 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 'h', 'h', - 0x00, 0x02, 'v', 'v', - - 0x80, spdy_version_ch_, 0x00, 0x08, // HEADERS on Stream #1 - 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x02, 'h', '2', - 0x00, 0x02, 'v', '2', - 0x00, 0x02, 'h', '3', - 0x00, 0x02, 'v', '3', - - 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 - 0x00, 0x00, 0x00, 0x0c, - 0xde, 0xad, 0xbe, 0xef, - 0xde, 0xad, 0xbe, 0xef, - 0xde, 0xad, 0xbe, 0xef, - - 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #3 - 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3 - 0x00, 0x00, 0x00, 0x08, - 0xde, 0xad, 0xbe, 0xef, - 0xde, 0xad, 0xbe, 0xef, - - 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 - 0x00, 0x00, 0x00, 0x04, - 0xde, 0xad, 0xbe, 0xef, - - 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #1 - 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x05, // RST_STREAM_CANCEL - - 0x00, 0x00, 0x00, 0x03, // DATA on Stream #3 - 0x00, 0x00, 0x00, 0x00, - - 0x80, spdy_version_ch_, 0x00, 0x03, // RST_STREAM on Stream #3 - 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x05, // RST_STREAM_CANCEL - }; - const unsigned char kV3Input[] = { 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x1a, @@ -1262,9 +1178,7 @@ TEST_P(SpdyFramerTest, Basic) { }; TestSpdyVisitor visitor(spdy_version_); - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); } else { visitor.SimulateInFramer(kH2Input, sizeof(kH2Input)); @@ -1294,32 +1208,6 @@ TEST_P(SpdyFramerTest, Basic) { // Test that the FIN flag on a data frame signifies EOF. TEST_P(SpdyFramerTest, FinOnDataFrame) { - const unsigned char kV2Input[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 - 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 'h', 'h', - 0x00, 0x02, 'v', 'v', - - 0x80, spdy_version_ch_, 0x00, 0x02, // SYN REPLY Stream #1 - 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 'a', 'a', - 0x00, 0x02, 'b', 'b', - - 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 - 0x00, 0x00, 0x00, 0x0c, - 0xde, 0xad, 0xbe, 0xef, - 0xde, 0xad, 0xbe, 0xef, - 0xde, 0xad, 0xbe, 0xef, - - 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1, with EOF - 0x01, 0x00, 0x00, 0x04, - 0xde, 0xad, 0xbe, 0xef, - }; const unsigned char kV3Input[] = { 0x80, spdy_version_ch_, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x1a, @@ -1376,9 +1264,7 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { }; TestSpdyVisitor visitor(spdy_version_); - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); } else { visitor.SimulateInFramer(kH2Input, sizeof(kH2Input)); @@ -1403,24 +1289,6 @@ TEST_P(SpdyFramerTest, FinOnDataFrame) { // Test that the FIN flag on a SYN reply frame signifies EOF. TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { - const unsigned char kV2Input[] = { - 0x80, spdy_version_ch_, 0x00, // SYN Stream #1 - 0x01, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x02, 'h', - 'h', 0x00, 0x02, 'v', - 'v', - - 0x80, spdy_version_ch_, 0x00, // SYN REPLY Stream #1 - 0x02, 0x01, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x02, 'a', - 'a', 0x00, 0x02, 'b', - 'b', - }; const unsigned char kV3Input[] = { 0x80, spdy_version_ch_, 0x00, // SYN Stream #1 0x01, 0x00, 0x00, 0x00, @@ -1456,9 +1324,7 @@ TEST_P(SpdyFramerTest, FinOnSynReplyFrame) { }; TestSpdyVisitor visitor(spdy_version_); - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2Input, sizeof(kV2Input)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3Input, sizeof(kV3Input)); } else { visitor.SimulateInFramer(kH2Input, sizeof(kH2Input)); @@ -1604,7 +1470,7 @@ TEST_P(SpdyFramerTest, WindowUpdateFrame) { SpdyWindowUpdateIR(1, 0x12345678))); const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, @@ -1629,7 +1495,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "'hello' data frame, no FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1673,7 +1539,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "'hello' data frame with more padding, no FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1733,7 +1599,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "'hello' data frame with few padding, no FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1766,7 +1632,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "'hello' data frame with 1 byte padding, no FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1804,7 +1670,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "Data frame with negative data byte, no FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xff @@ -1823,7 +1689,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "'hello' data frame, with FIN"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1848,9 +1714,8 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "Empty data frame"; - const unsigned char kV3FrameData[] = { // Also applies for V2. - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, + const unsigned char kV3FrameData[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, }; const unsigned char kH2FrameData[] = { 0x00, 0x00, 0x00, 0x00, @@ -1876,7 +1741,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { { const char kDescription[] = "Data frame with max stream ID"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x7f, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x05, 'h', 'e', 'l', 'l', @@ -1924,7 +1789,7 @@ TEST_P(SpdyFramerTest, CreateDataFrame) { } TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { - if (!IsSpdy2() && !IsSpdy3()) { + if (!IsSpdy3()) { // SYN_STREAM unsupported in SPDY>3 return; } @@ -1934,25 +1799,12 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { { const char kDescription[] = "SYN_STREAM frame, lowest pri, no FIN"; - const unsigned char kPri = IsSpdy2() ? 0xC0 : 0xE0; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, - kPri, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'b', 'a', 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - kPri, 0x00, 0x00, 0x00, + 0xE0, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 'b', 'a', 'r', 0x00, 0x00, 0x00, @@ -1967,9 +1819,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { syn_stream.SetHeader("bar", "foo"); syn_stream.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -1981,18 +1831,6 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { "SYN_STREAM frame with a 0-length header name, highest pri, FIN, " "max stream ID"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, - 0x01, 0x00, 0x00, 0x1D, - 0x7f, 0xff, 0xff, 0xff, - 0x7f, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'f', 'o', 'o', - 0x00, 0x03, 'b', 'a', - 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x27, @@ -2014,9 +1852,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { syn_stream.SetHeader("", "foo"); syn_stream.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -2028,25 +1864,12 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { "SYN_STREAM frame with a 0-length header val, high pri, FIN, " "max stream ID"; - const unsigned char kPri = IsSpdy2() ? 0x40 : 0x20; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, - 0x01, 0x00, 0x00, 0x1D, - 0x7f, 0xff, 0xff, 0xff, - 0x7f, 0xff, 0xff, 0xff, - kPri, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x00 - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x01, 0x01, 0x00, 0x00, 0x27, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, - kPri, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 'b', 'a', 'r', 0x00, 0x00, 0x00, @@ -2062,9 +1885,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { syn_stream.SetHeader("bar", "foo"); syn_stream.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -2076,7 +1897,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { // to workaround http://crbug.com/139744. #if !defined(USE_SYSTEM_ZLIB) TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { - if (!IsSpdy2() && !IsSpdy3()) { + if (!IsSpdy3()) { // SYN_STREAM not supported for SPDY>3 return; } @@ -2086,26 +1907,7 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { { const char kDescription[] = "SYN_STREAM frame, low pri, no FIN"; - const SpdyPriority priority = IsSpdy2() ? 2 : 4; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x36, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x4e, - 0xcb, 0xcf, 0x67, 0x60, - 0x06, 0x08, 0xa0, 0xa4, - 0xc4, 0x22, 0x80, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0xff, 0xff, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, @@ -2124,23 +1926,6 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { 0x80, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, }; - const unsigned char kV2SIMDFrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x33, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x06, - 0x13, 0x00, 0x01, 0x94, - 0x94, 0x58, 0x04, 0x10, - 0x40, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, - }; const unsigned char kV3SIMDFrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, @@ -2160,25 +1945,13 @@ TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { }; SpdySynStreamIR syn_stream(1); - syn_stream.set_priority(priority); + syn_stream.set_priority(4); syn_stream.SetHeader("bar", "foo"); syn_stream.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); const unsigned char* frame_data = reinterpret_cast<const unsigned char*>(frame->data()); - if (IsSpdy2()) { - // Try comparing with SIMD version, if that fails, do a failing check - // with pretty printing against non-SIMD version - if (memcmp(frame_data, - kV2SIMDFrameData, - std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { - CompareCharArraysWithHexError(kDescription, - frame_data, - frame->size(), - kV2FrameData, - arraysize(kV2FrameData)); - } - } else if (IsSpdy3()) { + if (IsSpdy3()) { if (memcmp(frame_data, kV3SIMDFrameData, std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { @@ -2206,17 +1979,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { { const char kDescription[] = "SYN_REPLY frame, no FIN"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x1C, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'b', 'a', 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x24, @@ -2234,9 +1996,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { syn_reply.SetHeader("bar", "foo"); syn_reply.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -2247,17 +2007,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { const char kDescription[] = "SYN_REPLY frame with a 0-length header name, FIN, max stream ID"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x19, - 0x7f, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'f', 'o', 'o', - 0x00, 0x03, 'b', 'a', - 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x21, @@ -2276,9 +2025,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { syn_reply.SetHeader("", "foo"); syn_reply.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -2289,17 +2036,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { const char kDescription[] = "SYN_REPLY frame with a 0-length header val, FIN, max stream ID"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x19, - 0x7f, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x00 - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x02, 0x01, 0x00, 0x00, 0x21, @@ -2318,9 +2054,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { syn_reply.SetHeader("bar", "foo"); syn_reply.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { LOG(FATAL) << "Unsupported version in test."; @@ -2342,23 +2076,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { { const char kDescription[] = "SYN_REPLY frame, no FIN"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x4e, - 0xcb, 0xcf, 0x67, 0x60, - 0x06, 0x08, 0xa0, 0xa4, - 0xc4, 0x22, 0x80, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0xff, 0xff, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x31, @@ -2376,22 +2093,6 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { 0x00, 0x00, 0x00, 0xff, 0xff, }; - const unsigned char kV2SIMDFrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x2f, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x06, - 0x13, 0x00, 0x01, 0x94, - 0x94, 0x58, 0x04, 0x10, - 0x40, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, - }; const unsigned char kV3SIMDFrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2c, @@ -2414,19 +2115,7 @@ TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); const unsigned char* frame_data = reinterpret_cast<const unsigned char*>(frame->data()); - if (IsSpdy2()) { - // Try comparing with SIMD version, if that fails, do a failing check - // with pretty printing against non-SIMD version - if (memcmp(frame_data, - kV2SIMDFrameData, - std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { - CompareCharArraysWithHexError(kDescription, - frame_data, - frame->size(), - kV2FrameData, - arraysize(kV2FrameData)); - } - } else if (IsSpdy3()) { + if (IsSpdy3()) { if (memcmp(frame_data, kV3SIMDFrameData, std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { @@ -2448,7 +2137,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, @@ -2469,7 +2158,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame with max stream ID"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, @@ -2492,7 +2181,7 @@ TEST_P(SpdyFramerTest, CreateRstStream) { { const char kDescription[] = "RST_STREAM frame with max status code"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, @@ -2520,13 +2209,6 @@ TEST_P(SpdyFramerTest, CreateSettings) { { const char kDescription[] = "Network byte order SETTINGS frame"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x01, - 0x07, 0x00, 0x00, 0x01, - 0x0a, 0x0b, 0x0c, 0x0d, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, @@ -2552,9 +2234,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { kValue); scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2564,19 +2244,6 @@ TEST_P(SpdyFramerTest, CreateSettings) { { const char kDescription[] = "Basic SETTINGS frame"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x24, - 0x00, 0x00, 0x00, 0x04, - 0x01, 0x00, 0x00, 0x00, // 1st Setting - 0x00, 0x00, 0x00, 0x05, - 0x02, 0x00, 0x00, 0x00, // 2nd Setting - 0x00, 0x00, 0x00, 0x06, - 0x03, 0x00, 0x00, 0x00, // 3rd Setting - 0x00, 0x00, 0x00, 0x07, - 0x04, 0x00, 0x00, 0x00, // 4th Setting - 0x00, 0x00, 0x00, 0x08, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, @@ -2625,9 +2292,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { 8); scoped_ptr<SpdyFrame> frame(framer.SerializeSettings(settings_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2637,7 +2302,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { { const char kDescription[] = "Empty SETTINGS frame"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, @@ -2662,7 +2327,7 @@ TEST_P(SpdyFramerTest, CreatePingFrame) { { const char kDescription[] = "PING frame"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x12, 0x34, 0x56, 0x78, @@ -2708,11 +2373,6 @@ TEST_P(SpdyFramerTest, CreateGoAway) { { const char kDescription[] = "GOAWAY frame"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, // Stream Id - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, @@ -2728,9 +2388,7 @@ TEST_P(SpdyFramerTest, CreateGoAway) { }; SpdyGoAwayIR goaway_ir(0, GOAWAY_OK, "GA"); scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2739,11 +2397,6 @@ TEST_P(SpdyFramerTest, CreateGoAway) { { const char kDescription[] = "GOAWAY frame with max stream ID, status"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, - 0x7f, 0xff, 0xff, 0xff, // Stream Id - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, @@ -2759,9 +2412,7 @@ TEST_P(SpdyFramerTest, CreateGoAway) { }; SpdyGoAwayIR goaway_ir(0x7FFFFFFF, GOAWAY_INTERNAL_ERROR, "GA"); scoped_ptr<SpdyFrame> frame(framer.SerializeGoAway(goaway_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2776,17 +2427,6 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { { const char kDescription[] = "HEADERS frame, no FIN"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x1C, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'b', 'a', 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, @@ -2813,9 +2453,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("bar", "foo"); headers_ir.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2826,17 +2464,6 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { const char kDescription[] = "HEADERS frame with a 0-length header name, FIN, max stream ID"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x08, - 0x01, 0x00, 0x00, 0x19, - 0x7f, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x03, 'f', 'o', 'o', - 0x00, 0x03, 'b', 'a', - 'r' - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x21, @@ -2863,9 +2490,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("", "foo"); headers_ir.SetHeader("foo", "bar"); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2876,17 +2501,6 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { const char kDescription[] = "HEADERS frame with a 0-length header val, FIN, max stream ID"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x08, - 0x01, 0x00, 0x00, 0x19, - 0x7f, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x02, - 0x00, 0x03, 'b', 'a', - 'r', 0x00, 0x03, 'f', - 'o', 'o', 0x00, 0x03, - 'f', 'o', 'o', 0x00, - 0x00 - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x08, 0x01, 0x00, 0x00, 0x21, @@ -2913,9 +2527,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("bar", "foo"); headers_ir.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2()) { - CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2943,7 +2555,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("bar", "foo"); headers_ir.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2() || IsSpdy3()) { + if (IsSpdy3()) { // HEADERS with priority not supported. } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -2974,7 +2586,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("bar", "foo"); headers_ir.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2() || IsSpdy3()) { + if (IsSpdy3()) { // HEADERS with priority not supported. } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -3005,7 +2617,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("bar", "foo"); headers_ir.SetHeader("foo", ""); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2() || IsSpdy3()) { + if (IsSpdy3()) { // HEADERS with priority not supported. } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -3034,7 +2646,7 @@ TEST_P(SpdyFramerTest, CreateHeadersUncompressed) { headers_ir.SetHeader("foo", "bar"); headers_ir.set_padding_len(6); scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); - if (IsSpdy2() || IsSpdy3()) { + if (IsSpdy3()) { // Padding is not supported. } else { CompareFrame(kDescription, *frame, kH2FrameData, arraysize(kH2FrameData)); @@ -3052,23 +2664,6 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) { { const char kDescription[] = "HEADERS frame, no FIN"; - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x4e, - 0xcb, 0xcf, 0x67, 0x60, - 0x06, 0x08, 0xa0, 0xa4, - 0xc4, 0x22, 0x80, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0xff, 0xff, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x31, @@ -3086,22 +2681,6 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) { 0x00, 0x00, 0x00, 0xff, 0xff, }; - const unsigned char kV2SIMDFrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x2f, - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x38, 0xea, - 0xdf, 0xa2, 0x51, 0xb2, - 0x62, 0x60, 0x62, 0x60, - 0x4e, 0x4a, 0x2c, 0x62, - 0x60, 0x06, 0x08, 0xa0, - 0xb4, 0xfc, 0x7c, 0x80, - 0x00, 0x62, 0x60, 0x06, - 0x13, 0x00, 0x01, 0x94, - 0x94, 0x58, 0x04, 0x10, - 0x40, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, - }; const unsigned char kV3SIMDFrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2c, @@ -3124,19 +2703,7 @@ TEST_P(SpdyFramerTest, CreateHeadersCompressed) { scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); const unsigned char* frame_data = reinterpret_cast<const unsigned char*>(frame->data()); - if (IsSpdy2()) { - // Try comparing with SIMD version, if that fails, do a failing check - // with pretty printing against non-SIMD version - if (memcmp(frame_data, - kV2SIMDFrameData, - std::min(arraysize(kV2SIMDFrameData), frame->size())) != 0) { - CompareCharArraysWithHexError(kDescription, - frame_data, - frame->size(), - kV2FrameData, - arraysize(kV2FrameData)); - } - } else if (IsSpdy3()) { + if (IsSpdy3()) { if (memcmp(frame_data, kV3SIMDFrameData, std::min(arraysize(kV3SIMDFrameData), frame->size())) != 0) { @@ -3158,7 +2725,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, @@ -3181,7 +2748,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x7f, 0xff, 0xff, 0xff, @@ -3204,7 +2771,7 @@ TEST_P(SpdyFramerTest, CreateWindowUpdate) { { const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, @@ -3873,7 +3440,7 @@ TEST_P(SpdyFramerTest, ControlFrameSizesAreValidated) { // We create enough overhead to overflow the framer's control frame buffer. ASSERT_LE(SpdyFramerPeer::ControlFrameBufferSize(), 250u); const size_t length = SpdyFramerPeer::ControlFrameBufferSize() + 1; - const unsigned char kV3FrameData[] = { // Also applies for V2. + const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, static_cast<unsigned char>(length), 0x00, 0x00, 0x00, 0x00, // Stream ID @@ -4013,17 +3580,6 @@ TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { TEST_P(SpdyFramerTest, ReadDuplicateSettings) { SpdyFramer framer(spdy_version_); - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x1C, - 0x00, 0x00, 0x00, 0x03, - 0x01, 0x00, 0x00, 0x00, // 1st Setting - 0x00, 0x00, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x00, // 2nd (duplicate) Setting - 0x00, 0x00, 0x00, 0x03, - 0x03, 0x00, 0x00, 0x00, // 3rd (unprocessed) Setting - 0x00, 0x00, 0x00, 0x03, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, @@ -4048,9 +3604,7 @@ TEST_P(SpdyFramerTest, ReadDuplicateSettings) { TestSpdyVisitor visitor(spdy_version_); visitor.use_compression_ = false; - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); } else { visitor.SimulateInFramer(kH2FrameData, sizeof(kH2FrameData)); @@ -4072,13 +3626,6 @@ TEST_P(SpdyFramerTest, ReadDuplicateSettings) { TEST_P(SpdyFramerTest, ReadUnknownSettingsId) { SpdyFramer framer(spdy_version_); - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x1C, - 0x00, 0x00, 0x00, 0x01, - 0x10, 0x00, 0x00, 0x00, // 1st Setting - 0x00, 0x00, 0x00, 0x02, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, @@ -4095,9 +3642,7 @@ TEST_P(SpdyFramerTest, ReadUnknownSettingsId) { TestSpdyVisitor visitor(spdy_version_); visitor.use_compression_ = false; - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); } else { visitor.SimulateInFramer(kH2FrameData, sizeof(kH2FrameData)); @@ -4117,17 +3662,6 @@ TEST_P(SpdyFramerTest, ReadUnknownSettingsId) { TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { SpdyFramer framer(spdy_version_); - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x1C, - 0x00, 0x00, 0x00, 0x03, - 0x02, 0x00, 0x00, 0x00, // 1st Setting - 0x00, 0x00, 0x00, 0x02, - 0x01, 0x00, 0x00, 0x00, // 2nd (out of order) Setting - 0x00, 0x00, 0x00, 0x03, - 0x03, 0x00, 0x00, 0x00, // 3rd (unprocessed) Setting - 0x00, 0x00, 0x00, 0x03, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1C, @@ -4152,9 +3686,7 @@ TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { TestSpdyVisitor visitor(spdy_version_); visitor.use_compression_ = false; - if (IsSpdy2()) { - visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); } else { visitor.SimulateInFramer(kH2FrameData, sizeof(kH2FrameData)); @@ -4736,12 +4268,12 @@ TEST_P(SpdyFramerTest, SizesTest) { EXPECT_EQ(8u, framer.GetDataFrameMinimumSize()); EXPECT_EQ(8u, framer.GetControlFrameHeaderSize()); EXPECT_EQ(18u, framer.GetSynStreamMinimumSize()); - EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetSynReplyMinimumSize()); + EXPECT_EQ(12u, framer.GetSynReplyMinimumSize()); EXPECT_EQ(16u, framer.GetRstStreamMinimumSize()); EXPECT_EQ(12u, framer.GetSettingsMinimumSize()); EXPECT_EQ(12u, framer.GetPingSize()); - EXPECT_EQ(IsSpdy2() ? 12u : 16u, framer.GetGoAwayMinimumSize()); - EXPECT_EQ(IsSpdy2() ? 14u : 12u, framer.GetHeadersMinimumSize()); + EXPECT_EQ(16u, framer.GetGoAwayMinimumSize()); + EXPECT_EQ(12u, framer.GetHeadersMinimumSize()); EXPECT_EQ(16u, framer.GetWindowUpdateSize()); EXPECT_EQ(8u, framer.GetFrameMinimumSize()); EXPECT_EQ(16777223u, framer.GetFrameMaximumSize()); @@ -4985,7 +4517,7 @@ TEST_P(SpdyFramerTest, DataFrameFlagsV4) { } TEST_P(SpdyFramerTest, SynStreamFrameFlags) { - if (!IsSpdy2() && !IsSpdy3()) { + if (!IsSpdy3()) { // SYN_STREAM not supported in SPDY>3 return; } @@ -5039,7 +4571,7 @@ TEST_P(SpdyFramerTest, SynStreamFrameFlags) { } TEST_P(SpdyFramerTest, SynReplyFrameFlags) { - if (!IsSpdy2() && !IsSpdy3()) { + if (!IsSpdy3()) { // SYN_REPLY not supported in SPDY>3 return; } @@ -5501,7 +5033,7 @@ TEST_P(SpdyFramerTest, ContinuationFrameFlags) { // TODO(hkhalil): Add TEST_P(SpdyFramerTest, BlockedFrameFlags) TEST_P(SpdyFramerTest, EmptySynStream) { - if (!IsSpdy2() && !IsSpdy3()) { + if (!IsSpdy3()) { // SYN_STREAM not supported in SPDY>3. return; } @@ -5535,8 +5067,7 @@ TEST_P(SpdyFramerTest, EmptySynStream) { TEST_P(SpdyFramerTest, SettingsFlagsAndId) { const uint32_t kId = 0x020304; const uint32_t kFlags = 0x01; - const uint32_t kWireFormat = - base::HostToNet32(IsSpdy2() ? 0x04030201 : 0x01020304); + const uint32_t kWireFormat = base::HostToNet32(0x01020304); SettingsFlagsAndId id_and_flags = SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); @@ -5613,9 +5144,6 @@ TEST_P(SpdyFramerTest, RstStreamStatusBounds) { // Test handling of GOAWAY frames with out-of-bounds status code. TEST_P(SpdyFramerTest, GoAwayStatusBounds) { - if (spdy_version_ <= SPDY2) { - return; - } SpdyFramer framer(spdy_version_); const unsigned char kV3FrameData[] = { @@ -5650,11 +5178,6 @@ TEST_P(SpdyFramerTest, GoAwayStatusBounds) { // Tests handling of a GOAWAY frame with out-of-bounds stream ID. TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) { - const unsigned char kV2FrameData[] = { - 0x80, spdy_version_ch_, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x04, - 0xff, 0xff, 0xff, 0xff, - }; const unsigned char kV3FrameData[] = { 0x80, spdy_version_ch_, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, @@ -5674,10 +5197,7 @@ TEST_P(SpdyFramerTest, GoAwayStreamIdBounds) { framer.set_visitor(&visitor); EXPECT_CALL(visitor, OnGoAway(0x7fffffff, GOAWAY_OK)); - if (IsSpdy2()) { - framer.ProcessInput(reinterpret_cast<const char*>(kV2FrameData), - arraysize(kV2FrameData)); - } else if (IsSpdy3()) { + if (IsSpdy3()) { framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), arraysize(kV3FrameData)); } else { diff --git a/net/spdy/spdy_headers_block_parser.cc b/net/spdy/spdy_headers_block_parser.cc index 27f52e8..83a2160 100644 --- a/net/spdy/spdy_headers_block_parser.cc +++ b/net/spdy/spdy_headers_block_parser.cc @@ -14,14 +14,17 @@ const SpdyStreamId kInvalidStreamId = 0; } // anonymous namespace +namespace { +const size_t kLengthFieldSize = sizeof(uint32_t); +} // anonymous namespace + const size_t SpdyHeadersBlockParser::kMaximumFieldLength = 16 * 1024; SpdyHeadersBlockParser::SpdyHeadersBlockParser( SpdyMajorVersion spdy_version, SpdyHeadersHandlerInterface* handler) : state_(READING_HEADER_BLOCK_LEN), - length_field_size_(LengthFieldSizeForVersion(spdy_version)), - max_headers_in_block_(MaxNumberOfHeadersForVersion(spdy_version)), + max_headers_in_block_(MaxNumberOfHeaders()), total_bytes_received_(0), remaining_key_value_pairs_for_frame_(0), handler_(handler), @@ -162,37 +165,22 @@ void SpdyHeadersBlockParser::ParseFieldLength(Reader* reader) { void SpdyHeadersBlockParser::ParseLength(Reader* reader, uint32_t* parsed_length) { char buffer[] = {0, 0, 0, 0}; - if (!reader->ReadN(length_field_size_, buffer)) { + if (!reader->ReadN(kLengthFieldSize, buffer)) { error_ = NEED_MORE_DATA; return; } // Convert from network to host order and return the parsed out integer. - if (length_field_size_ == sizeof(uint32_t)) { - *parsed_length = - base::NetToHost32(*reinterpret_cast<const uint32_t *>(buffer)); - } else { - *parsed_length = - base::NetToHost16(*reinterpret_cast<const uint16_t *>(buffer)); - } -} - -size_t SpdyHeadersBlockParser::LengthFieldSizeForVersion( - SpdyMajorVersion spdy_version) { - if (spdy_version < SPDY3) { - return sizeof(uint16_t); - } - return sizeof(uint32_t); + *parsed_length = + base::NetToHost32(*reinterpret_cast<const uint32_t*>(buffer)); } -size_t SpdyHeadersBlockParser::MaxNumberOfHeadersForVersion( - SpdyMajorVersion spdy_version) { +size_t SpdyHeadersBlockParser::MaxNumberOfHeaders() { // Account for the length of the header block field. - size_t max_bytes_for_headers = - kMaximumFieldLength - LengthFieldSizeForVersion(spdy_version); + size_t max_bytes_for_headers = kMaximumFieldLength - kLengthFieldSize; // A minimal size header is twice the length field size (and has a // zero-lengthed key and a zero-lengthed value). - return max_bytes_for_headers / (2 * LengthFieldSizeForVersion(spdy_version)); + return max_bytes_for_headers / (2 * kLengthFieldSize); } } // namespace net diff --git a/net/spdy/spdy_headers_block_parser.h b/net/spdy/spdy_headers_block_parser.h index 6f1dd67..4ee8760 100644 --- a/net/spdy/spdy_headers_block_parser.h +++ b/net/spdy/spdy_headers_block_parser.h @@ -64,11 +64,8 @@ class NET_EXPORT_PRIVATE SpdyHeadersBlockParser { SpdyMajorVersion spdy_version() const { return spdy_version_; } - // Returns the size in bytes of a length field in a SPDY header. - static size_t LengthFieldSizeForVersion(SpdyMajorVersion spdy_version); - // Returns the maximal number of headers in a SPDY headers block. - static size_t MaxNumberOfHeadersForVersion(SpdyMajorVersion spdy_version); + static size_t MaxNumberOfHeaders(); private: typedef SpdyPrefixedBufferReader Reader; @@ -93,9 +90,6 @@ class NET_EXPORT_PRIVATE SpdyHeadersBlockParser { }; ParserState state_; - // Size in bytes of a length field in the spdy header. - const size_t length_field_size_; - // The maximal number of headers in a SPDY headers block. const size_t max_headers_in_block_; diff --git a/net/spdy/spdy_headers_block_parser_test.cc b/net/spdy/spdy_headers_block_parser_test.cc index 433fda0..85beb6c 100644 --- a/net/spdy/spdy_headers_block_parser_test.cc +++ b/net/spdy/spdy_headers_block_parser_test.cc @@ -40,8 +40,6 @@ class SpdyHeadersBlockParserTest : spdy_version_ = GetParam(); parser_.reset(new SpdyHeadersBlockParser(spdy_version_, &handler_)); - length_field_size_ = - SpdyHeadersBlockParser::LengthFieldSizeForVersion(spdy_version_); } // Create a header block with a specified number of headers. @@ -80,19 +78,11 @@ class SpdyHeadersBlockParserTest : string EncodeLength(uint32_t len) { char buffer[4]; - if (length_field_size_ == sizeof(uint32_t)) { - uint32_t net_order_len = base::HostToNet32(len); - memcpy(buffer, &net_order_len, length_field_size_); - } else if (length_field_size_ == sizeof(uint16_t)) { - uint16_t net_order_len = base::HostToNet16(static_cast<uint16_t>(len)); - memcpy(buffer, &net_order_len, length_field_size_); - } else { - CHECK(false) << "Invalid length field size"; - } - return string(buffer, length_field_size_); + uint32_t net_order_len = base::HostToNet32(len); + memcpy(buffer, &net_order_len, sizeof(uint32_t)); + return string(buffer, sizeof(uint32_t)); } - size_t length_field_size_; SpdyMajorVersion spdy_version_; MockSpdyHeadersHandler handler_; @@ -109,10 +99,10 @@ class SpdyHeadersBlockParserTest : const char *const SpdyHeadersBlockParserTest::kBaseKey = "test_key"; const char *const SpdyHeadersBlockParserTest::kBaseValue = "test_value"; -// All tests are run with 3 different SPDY versions: SPDY/2, SPDY/3, HTTP/2. +// All tests are run with SPDY/3 and HTTP/2. INSTANTIATE_TEST_CASE_P(SpdyHeadersBlockParserTests, SpdyHeadersBlockParserTest, - ::testing::Values(SPDY2, SPDY3, HTTP2)); + ::testing::Values(SPDY3, HTTP2)); TEST_P(SpdyHeadersBlockParserTest, BasicTest) { // Sanity test, verify that we parse out correctly a block with @@ -218,8 +208,7 @@ TEST_P(SpdyHeadersBlockParserTest, HandlesEmptyCallsTest) { TEST_P(SpdyHeadersBlockParserTest, LargeBlocksDiscardedTest) { // Header block with too many headers. { - string headers = EncodeLength( - parser_->MaxNumberOfHeadersForVersion(spdy_version_) + 1); + string headers = EncodeLength(parser_->MaxNumberOfHeaders() + 1); EXPECT_FALSE(parser_-> HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); EXPECT_EQ(SpdyHeadersBlockParser::HEADER_BLOCK_TOO_LARGE, diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc index af55ac4..8692305 100644 --- a/net/spdy/spdy_http_utils.cc +++ b/net/spdy/spdy_http_utils.cc @@ -84,7 +84,7 @@ bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers, tval = value.substr(start, (end - start)); else tval = value.substr(start); - if (protocol_version >= 3 && it->first[0] == ':') + if (it->first[0] == ':') raw_headers.append(it->first.as_string().substr(1)); else raw_headers.append(it->first.as_string()); @@ -107,19 +107,6 @@ void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, SpdyHeaderBlock* headers) { static const char kHttpProtocolVersion[] = "HTTP/1.1"; switch (protocol_version) { - case SPDY2: - // TODO(bnc): Remove this code now that SPDY/2 is deprecated. - (*headers)["version"] = kHttpProtocolVersion; - (*headers)["method"] = info.method; - (*headers)["host"] = GetHostAndOptionalPort(info.url); - if (info.method == "CONNECT") { - (*headers)["url"] = GetHostAndPort(info.url); - } else { - (*headers)["scheme"] = info.url.scheme(); - (*headers)["url"] = direct ? info.url.PathForRequest() - : HttpUtil::SpecForRequest(info.url); - } - break; case SPDY3: (*headers)[":version"] = kHttpProtocolVersion; (*headers)[":method"] = info.method; diff --git a/net/spdy/spdy_http_utils_unittest.cc b/net/spdy/spdy_http_utils_unittest.cc index 7c1e89d..a53e331 100644 --- a/net/spdy/spdy_http_utils_unittest.cc +++ b/net/spdy/spdy_http_utils_unittest.cc @@ -42,23 +42,6 @@ TEST(SpdyHttpUtilsTest, ConvertSpdy3PriorityToRequestPriority) { } } -TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestSPDY2) { - GURL url("https://www.google.com/index.html"); - HttpRequestInfo request; - request.method = "GET"; - request.url = url; - request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1"); - SpdyHeaderBlock headers; - CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, SPDY2, - kDirect, &headers); - EXPECT_EQ("GET", headers["method"]); - EXPECT_EQ("https", headers["scheme"]); - EXPECT_EQ("www.google.com", headers["host"]); - EXPECT_EQ("/index.html", headers["url"]); - EXPECT_EQ("HTTP/1.1", headers["version"]); - EXPECT_EQ("Chrome/1.1", headers["user-agent"]); -} - TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestSPDY3) { GURL url("https://www.google.com/index.html"); HttpRequestInfo request; @@ -93,23 +76,6 @@ TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestHTTP2) { EXPECT_EQ("Chrome/1.1", headers["user-agent"]); } -TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestProxySPDY2) { - GURL url("https://www.google.com/index.html"); - HttpRequestInfo request; - request.method = "GET"; - request.url = url; - request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1"); - SpdyHeaderBlock headers; - CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, SPDY2, - !kDirect, &headers); - EXPECT_EQ("GET", headers["method"]); - EXPECT_EQ("https", headers["scheme"]); - EXPECT_EQ("www.google.com", headers["host"]); - EXPECT_EQ("https://www.google.com/index.html", headers["url"]); - EXPECT_EQ("HTTP/1.1", headers["version"]); - EXPECT_EQ("Chrome/1.1", headers["user-agent"]); -} - TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestProxySPDY3) { GURL url("https://www.google.com/index.html"); HttpRequestInfo request; @@ -144,23 +110,6 @@ TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestProxyHTTP2) { EXPECT_EQ("Chrome/1.1", headers["user-agent"]); } -TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestConnectSPDY2) { - GURL url("https://www.google.com/index.html"); - HttpRequestInfo request; - request.method = "CONNECT"; - request.url = url; - request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, "Chrome/1.1"); - SpdyHeaderBlock headers; - CreateSpdyHeadersFromHttpRequest(request, request.extra_headers, SPDY2, - kDirect, &headers); - EXPECT_EQ("CONNECT", headers["method"]); - EXPECT_TRUE(headers.end() == headers.find("scheme")); - EXPECT_EQ("www.google.com", headers["host"]); - EXPECT_EQ("www.google.com:443", headers["url"]); - EXPECT_EQ("HTTP/1.1", headers["version"]); - EXPECT_EQ("Chrome/1.1", headers["user-agent"]); -} - TEST(SpdyHttpUtilsTest, CreateSpdyHeadersFromHttpRequestConnectSPDY3) { GURL url("https://www.google.com/index.html"); HttpRequestInfo request; diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index d5b7a07..d701ddb 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -746,44 +746,24 @@ TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { // this repeats the RequestPriority-->SpdyPriority mapping from // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make // sure it's being done right. - if (spdy_util_.spdy_version() < SPDY3) { - switch (p) { - case HIGHEST: - EXPECT_EQ(0, spdy_prio); - break; - case MEDIUM: - EXPECT_EQ(1, spdy_prio); - break; - case LOW: - case LOWEST: - EXPECT_EQ(2, spdy_prio); - break; - case IDLE: - EXPECT_EQ(3, spdy_prio); - break; - default: - FAIL(); - } - } else { - switch (p) { - case HIGHEST: - EXPECT_EQ(0, spdy_prio); - break; - case MEDIUM: - EXPECT_EQ(1, spdy_prio); - break; - case LOW: - EXPECT_EQ(2, spdy_prio); - break; - case LOWEST: - EXPECT_EQ(3, spdy_prio); - break; - case IDLE: - EXPECT_EQ(4, spdy_prio); - break; - default: - FAIL(); - } + switch (p) { + case HIGHEST: + EXPECT_EQ(0, spdy_prio); + break; + case MEDIUM: + EXPECT_EQ(1, spdy_prio); + break; + case LOW: + EXPECT_EQ(2, spdy_prio); + break; + case LOWEST: + EXPECT_EQ(3, spdy_prio); + break; + case IDLE: + EXPECT_EQ(4, spdy_prio); + break; + default: + FAIL(); } scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); @@ -6349,9 +6329,6 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { } TEST_P(SpdyNetworkTransactionTest, GoAwayOnOddPushStreamId) { - if (spdy_util_.spdy_version() < SPDY3) - return; - scoped_ptr<SpdyHeaderBlock> push_headers(new SpdyHeaderBlock); spdy_util_.AddUrlToHeaderBlock("http://www.example.org/a.dat", push_headers.get()); @@ -6377,9 +6354,6 @@ TEST_P(SpdyNetworkTransactionTest, GoAwayOnOddPushStreamId) { TEST_P(SpdyNetworkTransactionTest, GoAwayOnPushStreamIdLesserOrEqualThanLastAccepted) { - if (spdy_util_.spdy_version() < SPDY3) - return; - scoped_ptr<SpdyFrame> push_a(spdy_util_.ConstructSpdyPush( NULL, 0, 4, 1, GetDefaultUrlWithPath("/a.dat").c_str())); scoped_ptr<SpdyHeaderBlock> push_b_headers(new SpdyHeaderBlock); diff --git a/net/spdy/spdy_protocol.cc b/net/spdy/spdy_protocol.cc index 1ef08b2..ca48c54 100644 --- a/net/spdy/spdy_protocol.cc +++ b/net/spdy/spdy_protocol.cc @@ -9,7 +9,6 @@ namespace net { bool SpdyConstants::IsValidFrameType(SpdyMajorVersion version, int frame_type_field) { switch (version) { - case SPDY2: case SPDY3: // SYN_STREAM is the first valid frame. if (frame_type_field < SerializeFrameType(version, SYN_STREAM)) { @@ -49,7 +48,6 @@ bool SpdyConstants::IsValidFrameType(SpdyMajorVersion version, SpdyFrameType SpdyConstants::ParseFrameType(SpdyMajorVersion version, int frame_type_field) { switch (version) { - case SPDY2: case SPDY3: switch (frame_type_field) { case 1: @@ -107,7 +105,6 @@ SpdyFrameType SpdyConstants::ParseFrameType(SpdyMajorVersion version, int SpdyConstants::SerializeFrameType(SpdyMajorVersion version, SpdyFrameType frame_type) { switch (version) { - case SPDY2: case SPDY3: switch (frame_type) { case SYN_STREAM: @@ -169,7 +166,6 @@ int SpdyConstants::SerializeFrameType(SpdyMajorVersion version, int SpdyConstants::DataFrameType(SpdyMajorVersion version) { switch (version) { - case SPDY2: case SPDY3: return 0; case HTTP2: @@ -183,7 +179,6 @@ int SpdyConstants::DataFrameType(SpdyMajorVersion version) { bool SpdyConstants::IsValidSettingId(SpdyMajorVersion version, int setting_id_field) { switch (version) { - case SPDY2: case SPDY3: // UPLOAD_BANDWIDTH is the first valid setting id. if (setting_id_field < @@ -221,7 +216,6 @@ bool SpdyConstants::IsValidSettingId(SpdyMajorVersion version, SpdySettingsIds SpdyConstants::ParseSettingId(SpdyMajorVersion version, int setting_id_field) { switch (version) { - case SPDY2: case SPDY3: switch (setting_id_field) { case 1: @@ -265,7 +259,6 @@ SpdySettingsIds SpdyConstants::ParseSettingId(SpdyMajorVersion version, int SpdyConstants::SerializeSettingId(SpdyMajorVersion version, SpdySettingsIds id) { switch (version) { - case SPDY2: case SPDY3: switch (id) { case SETTINGS_UPLOAD_BANDWIDTH: @@ -312,7 +305,6 @@ int SpdyConstants::SerializeSettingId(SpdyMajorVersion version, bool SpdyConstants::IsValidRstStreamStatus(SpdyMajorVersion version, int rst_stream_status_field) { switch (version) { - case SPDY2: case SPDY3: // PROTOCOL_ERROR is the valid first status code. if (rst_stream_status_field < @@ -361,7 +353,6 @@ SpdyRstStreamStatus SpdyConstants::ParseRstStreamStatus( SpdyMajorVersion version, int rst_stream_status_field) { switch (version) { - case SPDY2: case SPDY3: switch (rst_stream_status_field) { case 1: @@ -422,7 +413,6 @@ int SpdyConstants::SerializeRstStreamStatus( SpdyMajorVersion version, SpdyRstStreamStatus rst_stream_status) { switch (version) { - case SPDY2: case SPDY3: switch (rst_stream_status) { case RST_STREAM_PROTOCOL_ERROR: @@ -487,7 +477,6 @@ int SpdyConstants::SerializeRstStreamStatus( bool SpdyConstants::IsValidGoAwayStatus(SpdyMajorVersion version, int goaway_status_field) { switch (version) { - case SPDY2: case SPDY3: // GOAWAY_OK is the first valid status. if (goaway_status_field < SerializeGoAwayStatus(version, GOAWAY_OK)) { @@ -523,7 +512,6 @@ bool SpdyConstants::IsValidGoAwayStatus(SpdyMajorVersion version, SpdyGoAwayStatus SpdyConstants::ParseGoAwayStatus(SpdyMajorVersion version, int goaway_status_field) { switch (version) { - case SPDY2: case SPDY3: switch (goaway_status_field) { case 0: @@ -575,7 +563,6 @@ SpdyGoAwayStatus SpdyConstants::ParseGoAwayStatus(SpdyMajorVersion version, int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version, SpdyGoAwayStatus status) { switch (version) { - case SPDY2: case SPDY3: // TODO(jgraettinger): Merge this back to server-side. switch (status) { @@ -640,7 +627,6 @@ int SpdyConstants::SerializeGoAwayStatus(SpdyMajorVersion version, size_t SpdyConstants::GetDataFrameMinimumSize(SpdyMajorVersion version) { switch (version) { - case SPDY2: case SPDY3: return 8; case HTTP2: @@ -652,7 +638,6 @@ size_t SpdyConstants::GetDataFrameMinimumSize(SpdyMajorVersion version) { size_t SpdyConstants::GetControlFrameHeaderSize(SpdyMajorVersion version) { switch (version) { - case SPDY2: case SPDY3: return 8; case HTTP2: @@ -684,8 +669,8 @@ size_t SpdyConstants::GetFrameMaximumSize(SpdyMajorVersion version) { } } -size_t SpdyConstants::GetSizeOfSizeField(SpdyMajorVersion version) { - return (version < SPDY3) ? sizeof(uint16_t) : sizeof(uint32_t); +size_t SpdyConstants::GetSizeOfSizeField() { + return sizeof(uint32_t); } size_t SpdyConstants::GetSettingSize(SpdyMajorVersion version) { @@ -702,8 +687,6 @@ int32_t SpdyConstants::GetInitialSessionWindowSize(SpdyMajorVersion version) { SpdyMajorVersion SpdyConstants::ParseMajorVersion(int version_number) { switch (version_number) { - case 2: - return SPDY2; case 3: return SPDY3; case 4: @@ -716,8 +699,6 @@ SpdyMajorVersion SpdyConstants::ParseMajorVersion(int version_number) { int SpdyConstants::SerializeMajorVersion(SpdyMajorVersion version) { switch (version) { - case SPDY2: - return 2; case SPDY3: return 3; case HTTP2: @@ -730,8 +711,6 @@ int SpdyConstants::SerializeMajorVersion(SpdyMajorVersion version) { std::string SpdyConstants::GetVersionString(SpdyMajorVersion version) { switch (version) { - case SPDY2: - return "spdy/2"; case SPDY3: return "spdy/3"; case HTTP2: diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h index 1a39fee..86eb9b1 100644 --- a/net/spdy/spdy_protocol.h +++ b/net/spdy/spdy_protocol.h @@ -2,9 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file contains some protocol structures for use with SPDY 2 and 3 -// The SPDY 2 spec can be found at: -// http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 +// This file contains some protocol structures for use with SPDY 3 and HTTP 2 // The SPDY 3 spec can be found at: // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 @@ -33,13 +31,12 @@ namespace net { // The major versions of SPDY. Major version differences indicate // framer-layer incompatibility, as opposed to minor version numbers -// which indicate application-layer incompatibility. Do not rely on -// the mapping from enum value SPDYn to the integer n. +// which indicate application-layer incompatibility. It is NOT guaranteed +// that the enum value SPDYn maps to the integer n. enum SpdyMajorVersion { - SPDY2 = 2, - SPDY_MIN_VERSION = SPDY2, - SPDY3 = 3, - HTTP2 = 4, + SPDY3 = 1, + SPDY_MIN_VERSION = SPDY3, + HTTP2, SPDY_MAX_VERSION = HTTP2 }; @@ -62,24 +59,6 @@ const int32_t kSpdyMaximumWindowSize = 0x7FFFFFFF; // Max signed 32bit int // Maximum padding size in octets for one DATA or HEADERS or PUSH_PROMISE frame. const int32_t kPaddingSizePerFrame = 256; -// SPDY 2 dictionary. -// This is just a hacked dictionary to use for shrinking HTTP-like headers. -const char kV2Dictionary[] = - "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" - "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" - "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" - "-agent10010120020120220320420520630030130230330430530630740040140240340440" - "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" - "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" - "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" - "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" - "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" - "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" - "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" - "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" - ".1statusversionurl"; -const int kV2DictionarySize = arraysize(kV2Dictionary); - // SPDY 3 dictionary. const char kV3Dictionary[] = { 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69, // ....opti @@ -418,8 +397,6 @@ enum SpdyGoAwayStatus { }; // A SPDY priority is a number between 0 and 7 (inclusive). -// SPDY priority range is version-dependent. For SPDY 2 and below, priority is a -// number between 0 and 3. typedef uint8_t SpdyPriority; // Lowest and Highest here refer to SPDY priorities as described in @@ -529,9 +506,8 @@ class NET_EXPORT_PRIVATE SpdyConstants { static size_t GetFrameMaximumSize(SpdyMajorVersion version); - // Returns the size of a header block size field. Valid only for SPDY - // versions <= 3. - static size_t GetSizeOfSizeField(SpdyMajorVersion version); + // Returns the size of a header block size field. Valid only for SPDY 3. + static size_t GetSizeOfSizeField(); // Returns the size (in bytes) of a wire setting ID and value. static size_t GetSettingSize(SpdyMajorVersion version); diff --git a/net/spdy/spdy_protocol_test.cc b/net/spdy/spdy_protocol_test.cc index 6117994..c224818 100644 --- a/net/spdy/spdy_protocol_test.cc +++ b/net/spdy/spdy_protocol_test.cc @@ -14,47 +14,19 @@ namespace { -enum SpdyProtocolTestTypes { - SPDY2 = net::SPDY2, - SPDY3 = net::SPDY3, -}; - } // namespace namespace net { -class SpdyProtocolTest - : public ::testing::TestWithParam<SpdyProtocolTestTypes> { - protected: - void SetUp() override { - spdy_version_ = static_cast<SpdyMajorVersion>(GetParam()); - } - - // Version of SPDY protocol to be used. - SpdyMajorVersion spdy_version_; -}; - -// All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. -INSTANTIATE_TEST_CASE_P(SpdyProtocolTests, - SpdyProtocolTest, - ::testing::Values(SPDY2, SPDY3)); - -class SpdyProtocolDeathTest : public SpdyProtocolTest {}; - -// All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. -INSTANTIATE_TEST_CASE_P(SpdyProtocolDeathTests, - SpdyProtocolDeathTest, - ::testing::Values(SPDY2, SPDY3)); - -TEST_P(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { +TEST(SpdyProtocolDeathTest, TestSpdySettingsAndIdOutOfBounds) { scoped_ptr<SettingsFlagsAndId> flags_and_id; - EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xFFFFFFFF)), + EXPECT_DFATAL(flags_and_id.reset(new SettingsFlagsAndId(1, 0xffffffff)), "SPDY setting ID too large."); // Make sure that we get expected values in opt mode. - if (flags_and_id.get() != NULL) { + if (flags_and_id.get() != nullptr) { EXPECT_EQ(1, flags_and_id->flags()); - EXPECT_EQ(static_cast<SpdyPingId>(0xffffff), flags_and_id->id()); + EXPECT_EQ(0xffffffu, flags_and_id->id()); } } diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index a2fec98..64a7f62 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -465,15 +465,11 @@ void SplitPushedHeadersToRequestAndResponse(const SpdyHeaderBlock& headers, it != headers.end(); ++it) { SpdyHeaderBlock* to_insert = response_headers; - if (protocol_version == SPDY2) { - if (it->first == "url") - to_insert = request_headers; - } else { - const char* host = protocol_version >= HTTP2 ? ":authority" : ":host"; - static const char scheme[] = ":scheme"; - static const char path[] = ":path"; - if (it->first == host || it->first == scheme || it->first == path) - to_insert = request_headers; + const char* host = protocol_version >= HTTP2 ? ":authority" : ":host"; + static const char scheme[] = ":scheme"; + static const char path[] = ":path"; + if (it->first == host || it->first == scheme || it->first == path) { + to_insert = request_headers; } to_insert->insert(*it); } @@ -767,10 +763,8 @@ void SpdySession::InitializeWithSocket( flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; session_send_window_size_ = GetDefaultInitialWindowSize(protocol_); session_recv_window_size_ = GetDefaultInitialWindowSize(protocol_); - } else if (protocol_ >= kProtoSPDY3) { - flow_control_state_ = FLOW_CONTROL_STREAM; } else { - flow_control_state_ = FLOW_CONTROL_NONE; + flow_control_state_ = FLOW_CONTROL_STREAM; } buffered_spdy_framer_.reset( @@ -2640,20 +2634,17 @@ bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id, // Server-initiated streams should have even sequence numbers. if ((stream_id & 0x1) != 0) { LOG(WARNING) << "Received invalid push stream id " << stream_id; - if (GetProtocolVersion() > SPDY2) - CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id."); + CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id."); return false; } - if (GetProtocolVersion() > SPDY2) { - if (stream_id <= last_accepted_push_stream_id_) { - LOG(WARNING) << "Received push stream id lesser or equal to the last " - << "accepted before " << stream_id; - CloseSessionOnError( - ERR_SPDY_PROTOCOL_ERROR, - "New push stream id must be greater than the last accepted."); - return false; - } + if (stream_id <= last_accepted_push_stream_id_) { + LOG(WARNING) << "Received push stream id lesser or equal to the last " + << "accepted before " << stream_id; + CloseSessionOnError( + ERR_SPDY_PROTOCOL_ERROR, + "New push stream id must be greater than the last accepted."); + return false; } if (IsStreamActive(stream_id)) { diff --git a/net/spdy/spdy_test_utils.cc b/net/spdy/spdy_test_utils.cc index bc0dc17..668a902 100644 --- a/net/spdy/spdy_test_utils.cc +++ b/net/spdy/spdy_test_utils.cc @@ -92,7 +92,6 @@ void SetFrameFlags(SpdyFrame* frame, uint8_t flags, SpdyMajorVersion spdy_version) { switch (spdy_version) { - case SPDY2: case SPDY3: case HTTP2: frame->data()[4] = flags; @@ -106,12 +105,11 @@ void SetFrameLength(SpdyFrame* frame, size_t length, SpdyMajorVersion spdy_version) { switch (spdy_version) { - case SPDY2: case SPDY3: CHECK_EQ(0u, length & ~kLengthMask); { int32_t wire_length = base::HostToNet32(length); - // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at + // The length field in SPDY 3 is a 24-bit (3B) integer starting at // offset 5. memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); } diff --git a/net/tools/flip_server/sm_connection.cc b/net/tools/flip_server/sm_connection.cc index eb6a9ee..ea874e2 100644 --- a/net/tools/flip_server/sm_connection.cc +++ b/net/tools/flip_server/sm_connection.cc @@ -319,12 +319,6 @@ bool SMConnection::WasSpdyNegotiated(SpdyMajorVersion* version_negotiated) { VLOG(1) << log_prefix_ << ACCEPTOR_CLIENT_IDENT << "NPN protocol detected: " << npn_proto_str; if (!strncmp(reinterpret_cast<const char*>(npn_proto), - "spdy/2", - npn_proto_len)) { - *version_negotiated = SPDY2; - return true; - } - if (!strncmp(reinterpret_cast<const char*>(npn_proto), "spdy/3", npn_proto_len)) { *version_negotiated = SPDY3; diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc index 30f423d..d083940 100644 --- a/net/tools/flip_server/spdy_interface.cc +++ b/net/tools/flip_server/spdy_interface.cc @@ -139,39 +139,19 @@ int SpdySM::SpdyHandleNewStream(SpdyStreamId stream_id, std::string path_string, host_string, version_string; - if (spdy_version() == SPDY2) { - url = headers.find("url"); - method = headers.find("method"); - version = headers.find("version"); - scheme = headers.find("scheme"); - if (url == headers.end() || method == headers.end() || - version == headers.end() || scheme == headers.end()) { - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is " - << "missing. Not creating stream"; - return 0; - } - // url->second here only ever seems to contain just the path. When this - // path contains a query string with a http:// in one of its values, - // UrlUtilities::GetUrlPath will fail and always return a / breaking - // the request. GetUrlPath assumes the absolute URL is being passed in. - path_string = UrlUtilities::GetUrlPath(url->second.as_string()); - host_string = UrlUtilities::GetUrlHost(url->second.as_string()); - version_string = version->second.as_string(); - } else { - method = headers.find(":method"); - host = headers.find(":host"); - path = headers.find(":path"); - scheme = headers.find(":scheme"); - if (method == headers.end() || host == headers.end() || - path == headers.end() || scheme == headers.end()) { - VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is " - << "missing. Not creating stream"; - return 0; - } - host_string = host->second.as_string(); - path_string = path->second.as_string(); - version_string = "HTTP/1.1"; + method = headers.find(":method"); + host = headers.find(":host"); + path = headers.find(":path"); + scheme = headers.find(":scheme"); + if (method == headers.end() || host == headers.end() || + path == headers.end() || scheme == headers.end()) { + VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: A mandatory header is " + << "missing. Not creating stream"; + return 0; } + host_string = host->second.as_string(); + path_string = path->second.as_string(); + version_string = "HTTP/1.1"; if (scheme->second.compare("https") == 0) { *is_https_scheme = true; @@ -472,31 +452,17 @@ size_t SpdySM::SendSynStreamImpl(uint32_t stream_id, const BalsaHeaders& headers) { SpdyHeaderBlock block; CopyHeaders(block, headers); - if (spdy_version() == SPDY2) { - block["method"] = headers.request_method().as_string(); - if (!headers.HasHeader("version")) - block["version"] = headers.request_version().as_string(); - if (headers.HasHeader("X-Original-Url")) { - std::string original_url = - headers.GetHeader("X-Original-Url").as_string(); - block["url"] = UrlUtilities::GetUrlPath(original_url); - } else { - block["url"] = headers.request_uri().as_string(); - } + block[":method"] = headers.request_method().as_string(); + block[":version"] = headers.request_version().as_string(); + if (headers.HasHeader("X-Original-Url")) { + std::string original_url = headers.GetHeader("X-Original-Url").as_string(); + block[":path"] = UrlUtilities::GetUrlPath(original_url); + block[":host"] = UrlUtilities::GetUrlPath(original_url); } else { - block[":method"] = headers.request_method().as_string(); - block[":version"] = headers.request_version().as_string(); - if (headers.HasHeader("X-Original-Url")) { - std::string original_url = - headers.GetHeader("X-Original-Url").as_string(); - block[":path"] = UrlUtilities::GetUrlPath(original_url); - block[":host"] = UrlUtilities::GetUrlPath(original_url); - } else { - block[":path"] = headers.request_uri().as_string(); - if (block.find("host") != block.end()) { - block[":host"] = headers.GetHeader("Host").as_string(); - block.erase("host"); - } + block[":path"] = headers.request_uri().as_string(); + if (block.find("host") != block.end()) { + block[":host"] = headers.GetHeader("Host").as_string(); + block.erase("host"); } } @@ -515,15 +481,9 @@ size_t SpdySM::SendSynReplyImpl(uint32_t stream_id, const BalsaHeaders& headers) { SpdyHeaderBlock block; CopyHeaders(block, headers); - if (spdy_version() == SPDY2) { - block["status"] = headers.response_code().as_string() + " " + - headers.response_reason_phrase().as_string(); - block["version"] = headers.response_version().as_string(); - } else { - block[":status"] = headers.response_code().as_string() + " " + - headers.response_reason_phrase().as_string(); - block[":version"] = headers.response_version().as_string(); - } + block[":status"] = headers.response_code().as_string() + " " + + headers.response_reason_phrase().as_string(); + block[":version"] = headers.response_version().as_string(); DCHECK(buffered_spdy_framer_); SpdyFrame* fsrcf = buffered_spdy_framer_->CreateSynReply( |