OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
10 #include "net/spdy/spdy_protocol.h" | 10 #include "net/spdy/spdy_protocol.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 LOG(ERROR) << "Expected header named '" << it->first | 498 LOG(ERROR) << "Expected header named '" << it->first |
499 << "' to have a value of '" << it->second | 499 << "' to have a value of '" << it->second |
500 << "'. The actual value received was '" << it2->second | 500 << "'. The actual value received was '" << it2->second |
501 << "'." << std::endl; | 501 << "'." << std::endl; |
502 return false; | 502 return false; |
503 } | 503 } |
504 } | 504 } |
505 return true; | 505 return true; |
506 } | 506 } |
507 | 507 |
508 SpdySetting SpdySettingFromWireFormat(uint32 key, uint32 value) { | 508 void AddSpdySettingFromWireFormat(SettingsMap* settings, |
509 return SpdySetting( | 509 uint32 key, |
510 SettingsFlagsAndId::FromWireFormat(spdy_version_, key), | 510 uint32 value) { |
511 value); | 511 SettingsFlagsAndId flags_and_id = |
512 SettingsFlagsAndId::FromWireFormat(spdy_version_, key); | |
513 SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); | |
514 SpdySettingsFlags flags = | |
515 static_cast<SpdySettingsFlags>(flags_and_id.flags()); | |
516 settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value))); | |
512 } | 517 } |
513 | 518 |
514 bool IsSpdy2() { return spdy_version_ < 3; } | 519 bool IsSpdy2() { return spdy_version_ < 3; } |
515 | 520 |
516 // Version of SPDY protocol to be used. | 521 // Version of SPDY protocol to be used. |
517 int spdy_version_; | 522 int spdy_version_; |
518 }; | 523 }; |
519 | 524 |
520 | 525 |
521 //----------------------------------------------------------------------------- | 526 //----------------------------------------------------------------------------- |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1842 } | 1847 } |
1843 } | 1848 } |
1844 | 1849 |
1845 TEST_P(SpdyFramerTest, CreateSettings) { | 1850 TEST_P(SpdyFramerTest, CreateSettings) { |
1846 SpdyFramer framer(spdy_version_); | 1851 SpdyFramer framer(spdy_version_); |
1847 | 1852 |
1848 { | 1853 { |
1849 const char kDescription[] = "Network byte order SETTINGS frame"; | 1854 const char kDescription[] = "Network byte order SETTINGS frame"; |
1850 | 1855 |
1851 uint32 kValue = 0x0a0b0c0d; | 1856 uint32 kValue = 0x0a0b0c0d; |
1852 uint8 kFlags = 0x04; | 1857 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x04); |
1853 uint32 kId = 0x030201; | 1858 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x030201); |
1854 SettingsFlagsAndId idAndFlags(kFlags, kId); | |
1855 | 1859 |
1856 SpdySettings settings; | 1860 SettingsMap settings; |
1857 settings.push_back(SpdySetting(idAndFlags, kValue)); | 1861 settings[kId] = SettingsFlagsAndValue(kFlags, kValue); |
1858 | 1862 |
1859 EXPECT_EQ(kValue, settings.back().second); | 1863 EXPECT_EQ(kFlags, settings[kId].first); |
1860 EXPECT_EQ(kFlags, settings.back().first.flags()); | 1864 EXPECT_EQ(kValue, settings[kId].second); |
1861 EXPECT_EQ(kId, settings.back().first.id()); | |
1862 | 1865 |
1863 const unsigned char kFrameDatav2[] = { | 1866 const unsigned char kFrameDatav2[] = { |
1864 0x80, spdy_version_, 0x00, 0x04, | 1867 0x80, spdy_version_, 0x00, 0x04, |
1865 0x00, 0x00, 0x00, 0x0c, | 1868 0x00, 0x00, 0x00, 0x0c, |
1866 0x00, 0x00, 0x00, 0x01, | 1869 0x00, 0x00, 0x00, 0x01, |
1867 0x01, 0x02, 0x03, 0x04, | 1870 0x01, 0x02, 0x03, 0x04, |
1868 0x0a, 0x0b, 0x0c, 0x0d, | 1871 0x0a, 0x0b, 0x0c, 0x0d, |
1869 }; | 1872 }; |
1870 | 1873 |
1871 const unsigned char kFrameDatav3[] = { | 1874 const unsigned char kFrameDatav3[] = { |
1872 0x80, spdy_version_, 0x00, 0x04, | 1875 0x80, spdy_version_, 0x00, 0x04, |
1873 0x00, 0x00, 0x00, 0x0c, | 1876 0x00, 0x00, 0x00, 0x0c, |
1874 0x00, 0x00, 0x00, 0x01, | 1877 0x00, 0x00, 0x00, 0x01, |
1875 0x04, 0x03, 0x02, 0x01, | 1878 0x04, 0x03, 0x02, 0x01, |
1876 0x0a, 0x0b, 0x0c, 0x0d, | 1879 0x0a, 0x0b, 0x0c, 0x0d, |
1877 }; | 1880 }; |
1878 | 1881 |
1879 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); | 1882 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); |
1880 CompareFrame(kDescription, | 1883 CompareFrame(kDescription, |
1881 *frame, | 1884 *frame, |
1882 (IsSpdy2()) ? kFrameDatav2 : kFrameDatav3, | 1885 (IsSpdy2()) ? kFrameDatav2 : kFrameDatav3, |
1883 arraysize(kFrameDatav3)); // Size is unchanged among versions. | 1886 arraysize(kFrameDatav3)); // Size is unchanged among versions. |
1884 EXPECT_EQ(SpdyFramer::kInvalidStream, | 1887 EXPECT_EQ(SpdyFramer::kInvalidStream, |
1885 SpdyFramer::GetControlFrameStreamId(frame.get())); | 1888 SpdyFramer::GetControlFrameStreamId(frame.get())); |
1886 | 1889 |
1887 // Make sure that ParseSettings also works as advertised. | 1890 // Make sure that ParseSettings also works as advertised. |
1888 SpdySettings parsed_settings; | 1891 SettingsMap parsed_settings; |
1889 EXPECT_TRUE(framer.ParseSettings(frame.get(), &parsed_settings)); | 1892 EXPECT_TRUE(framer.ParseSettings(frame.get(), &parsed_settings)); |
1890 EXPECT_EQ(settings.size(), parsed_settings.size()); | 1893 EXPECT_EQ(settings.size(), parsed_settings.size()); |
1891 EXPECT_EQ(kFlags, parsed_settings.back().first.flags()); | 1894 EXPECT_EQ(kFlags, parsed_settings[kId].first); |
1892 EXPECT_EQ(kId, parsed_settings.back().first.id()); | 1895 EXPECT_EQ(kValue, parsed_settings[kId].second); |
1893 } | 1896 } |
1894 | 1897 |
1895 { | 1898 { |
1896 const char kDescription[] = "Basic SETTINGS frame"; | 1899 const char kDescription[] = "Basic SETTINGS frame"; |
1897 | 1900 |
1898 SpdySettings settings; | 1901 SettingsMap settings; |
1899 settings.push_back( | 1902 AddSpdySettingFromWireFormat( |
1900 SpdySettingFromWireFormat(0x00000000, 0x00000000)); // 1st Setting | 1903 &settings, 0x00000000, 0x00000001); // 1st Setting |
1901 settings.push_back( | 1904 AddSpdySettingFromWireFormat( |
1902 SpdySettingFromWireFormat(0xffffffff, 0x00000001)); // 2nd Setting | 1905 &settings, 0x01000002, 0x00000002); // 2nd Setting |
1903 settings.push_back( | 1906 AddSpdySettingFromWireFormat( |
1904 SpdySettingFromWireFormat(0xff000001, 0x00000002)); // 3rd Setting | 1907 &settings, 0x02000003, 0x00000003); // 3rd Setting |
1905 | 1908 AddSpdySettingFromWireFormat( |
1906 // Duplicates allowed | 1909 &settings, 0x03000004, 0xff000004); // 4th Setting |
1907 settings.push_back( | 1910 AddSpdySettingFromWireFormat( |
1908 SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 4th Setting | 1911 &settings, 0xff000005, 0x00000005); // 5th Setting |
1909 settings.push_back( | 1912 AddSpdySettingFromWireFormat( |
1910 SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 5th Setting | 1913 &settings, 0xffffffff, 0x00000006); // 6th Setting |
1911 | |
1912 settings.push_back( | |
1913 SpdySettingFromWireFormat(0x01000003, 0x000000ff)); // 6th Setting | |
1914 settings.push_back( | |
1915 SpdySettingFromWireFormat(0x01000004, 0xff000001)); // 7th Setting | |
1916 settings.push_back( | |
1917 SpdySettingFromWireFormat(0x01000004, 0xffffffff)); // 8th Setting | |
1918 | 1914 |
1919 const unsigned char kFrameData[] = { | 1915 const unsigned char kFrameData[] = { |
1920 0x80, spdy_version_, 0x00, 0x04, | 1916 0x80, spdy_version_, 0x00, 0x04, |
1921 0x00, 0x00, 0x00, 0x44, | 1917 0x00, 0x00, 0x00, 0x34, |
1922 0x00, 0x00, 0x00, 0x08, | 1918 0x00, 0x00, 0x00, 0x06, |
1923 0x00, 0x00, 0x00, 0x00, // 1st Setting | 1919 0x00, 0x00, 0x00, 0x00, // 1st Setting |
1924 0x00, 0x00, 0x00, 0x00, | |
1925 0xff, 0xff, 0xff, 0xff, // 2nd Setting | |
1926 0x00, 0x00, 0x00, 0x01, | 1920 0x00, 0x00, 0x00, 0x01, |
1927 0x01, 0x00, 0x00, 0xff, // 3rd Setting | 1921 0x02, 0x00, 0x00, 0x01, // 2nd Setting |
1928 0x00, 0x00, 0x00, 0x02, | 1922 0x00, 0x00, 0x00, 0x02, |
1929 0x02, 0x00, 0x00, 0x01, // 4th Setting | 1923 0x03, 0x00, 0x00, 0x02, // 3rd Setting |
1930 0x00, 0x00, 0x00, 0x03, | 1924 0x00, 0x00, 0x00, 0x03, |
1931 0x02, 0x00, 0x00, 0x01, // 5th Setting | 1925 0x04, 0x00, 0x00, 0x03, // 4th Setting |
1932 0x00, 0x00, 0x00, 0x03, | 1926 0xff, 0x00, 0x00, 0x04, |
1933 0x03, 0x00, 0x00, 0x01, // 6th Setting | 1927 0x05, 0x00, 0x00, 0xff, // 5th Setting |
1934 0x00, 0x00, 0x00, 0xff, | 1928 0x00, 0x00, 0x00, 0x05, |
1935 0x04, 0x00, 0x00, 0x01, // 7th Setting | 1929 0xff, 0xff, 0xff, 0xff, // 6th Setting |
1936 0xff, 0x00, 0x00, 0x01, | 1930 0x00, 0x00, 0x00, 0x06, |
1937 0x04, 0x00, 0x00, 0x01, // 8th Setting | |
1938 0xff, 0xff, 0xff, 0xff, | |
1939 }; | 1931 }; |
1940 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); | 1932 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); |
1941 CompareFrame(kDescription, | 1933 CompareFrame(kDescription, |
1942 *frame, | 1934 *frame, |
1943 kFrameData, | 1935 kFrameData, |
1944 arraysize(kFrameData)); | 1936 arraysize(kFrameData)); |
1945 EXPECT_EQ(SpdyFramer::kInvalidStream, | 1937 EXPECT_EQ(SpdyFramer::kInvalidStream, |
1946 SpdyFramer::GetControlFrameStreamId(frame.get())); | 1938 SpdyFramer::GetControlFrameStreamId(frame.get())); |
1947 } | 1939 } |
1948 | 1940 |
1949 { | 1941 { |
1950 const char kDescription[] = "Empty SETTINGS frame"; | 1942 const char kDescription[] = "Empty SETTINGS frame"; |
1951 | 1943 |
1952 SpdySettings settings; | 1944 SettingsMap settings; |
1953 | 1945 |
1954 const unsigned char kFrameData[] = { | 1946 const unsigned char kFrameData[] = { |
1955 0x80, spdy_version_, 0x00, 0x04, | 1947 0x80, spdy_version_, 0x00, 0x04, |
1956 0x00, 0x00, 0x00, 0x04, | 1948 0x00, 0x00, 0x00, 0x04, |
1957 0x00, 0x00, 0x00, 0x00, | 1949 0x00, 0x00, 0x00, 0x00, |
1958 }; | 1950 }; |
1959 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); | 1951 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); |
1960 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 1952 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
1961 } | 1953 } |
1962 } | 1954 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2312 reinterpret_cast<const unsigned char*>(pad.c_str()), | 2304 reinterpret_cast<const unsigned char*>(pad.c_str()), |
2313 overhead); | 2305 overhead); |
2314 EXPECT_EQ(1, visitor.error_count_); // This generated an error. | 2306 EXPECT_EQ(1, visitor.error_count_); // This generated an error. |
2315 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 2307 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
2316 visitor.framer_.error_code()); | 2308 visitor.framer_.error_code()); |
2317 EXPECT_EQ(0, visitor.goaway_count_); // Frame not parsed. | 2309 EXPECT_EQ(0, visitor.goaway_count_); // Frame not parsed. |
2318 } | 2310 } |
2319 | 2311 |
2320 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { | 2312 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { |
2321 SpdyFramer framer(spdy_version_); | 2313 SpdyFramer framer(spdy_version_); |
2322 SpdySettings settings; | 2314 SettingsMap settings; |
2323 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2315 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2324 control_frame->set_length(0); | 2316 control_frame->set_length(0); |
2325 TestSpdyVisitor visitor(spdy_version_); | 2317 TestSpdyVisitor visitor(spdy_version_); |
2326 visitor.use_compression_ = false; | 2318 visitor.use_compression_ = false; |
2327 visitor.SimulateInFramer( | 2319 visitor.SimulateInFramer( |
2328 reinterpret_cast<unsigned char*>(control_frame->data()), | 2320 reinterpret_cast<unsigned char*>(control_frame->data()), |
2329 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); | 2321 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); |
2330 // Should generate an error, since zero-len settings frames are unsupported. | 2322 // Should generate an error, since zero-len settings frames are unsupported. |
2331 EXPECT_EQ(1, visitor.error_count_); | 2323 EXPECT_EQ(1, visitor.error_count_); |
2332 } | 2324 } |
2333 | 2325 |
2334 // Tests handling of SETTINGS frames with invalid length. | 2326 // Tests handling of SETTINGS frames with invalid length. |
2335 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { | 2327 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { |
2336 SpdyFramer framer(spdy_version_); | 2328 SpdyFramer framer(spdy_version_); |
2337 SpdySettings settings; | 2329 SettingsMap settings; |
2338 // Add a setting to pad the frame so that we don't get a buffer overflow when | 2330 // Add a setting to pad the frame so that we don't get a buffer overflow when |
2339 // calling SimulateInFramer() below. | 2331 // calling SimulateInFramer() below. |
2340 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | 2332 settings[SETTINGS_UPLOAD_BANDWIDTH] = |
2333 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); | |
2341 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2334 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2342 control_frame->set_length(5); | 2335 control_frame->set_length(5); |
2343 TestSpdyVisitor visitor(spdy_version_); | 2336 TestSpdyVisitor visitor(spdy_version_); |
2344 visitor.use_compression_ = false; | 2337 visitor.use_compression_ = false; |
2345 visitor.SimulateInFramer( | 2338 visitor.SimulateInFramer( |
2346 reinterpret_cast<unsigned char*>(control_frame->data()), | 2339 reinterpret_cast<unsigned char*>(control_frame->data()), |
2347 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); | 2340 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); |
2348 // Should generate an error, since zero-len settings frames are unsupported. | 2341 // Should generate an error, since zero-len settings frames are unsupported. |
2349 EXPECT_EQ(1, visitor.error_count_); | 2342 EXPECT_EQ(1, visitor.error_count_); |
2350 } | 2343 } |
2351 | 2344 |
2352 // Tests handling of SETTINGS frames larger than the frame buffer size. | 2345 // Tests handling of SETTINGS frames larger than the frame buffer size. |
2353 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { | 2346 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { |
2354 SpdyFramer framer(spdy_version_); | 2347 SpdyFramer framer(spdy_version_); |
2355 SpdySettings settings; | 2348 SettingsMap settings; |
2356 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | 2349 SpdySettingsFlags flags = SETTINGS_FLAG_NONE; |
2357 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000003)); | 2350 settings[SETTINGS_UPLOAD_BANDWIDTH] = |
2358 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000004)); | 2351 SettingsFlagsAndValue(flags, 0x00000002); |
2352 settings[SETTINGS_DOWNLOAD_BANDWIDTH] = | |
2353 SettingsFlagsAndValue(flags, 0x00000003); | |
2354 settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000004); | |
2359 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2355 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2360 EXPECT_LT(SpdyFramer::kUncompressedControlFrameBufferInitialSize, | 2356 EXPECT_LT(SpdyFramer::kUncompressedControlFrameBufferInitialSize, |
2361 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2357 control_frame->length() + SpdyControlFrame::kHeaderSize); |
2362 TestSpdyVisitor visitor(spdy_version_); | 2358 TestSpdyVisitor visitor(spdy_version_); |
2363 visitor.use_compression_ = false; | 2359 visitor.use_compression_ = false; |
2364 | 2360 |
2365 // Read all at once. | 2361 // Read all at once. |
2366 visitor.SimulateInFramer( | 2362 visitor.SimulateInFramer( |
2367 reinterpret_cast<unsigned char*>(control_frame->data()), | 2363 reinterpret_cast<unsigned char*>(control_frame->data()), |
2368 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2364 control_frame->length() + SpdyControlFrame::kHeaderSize); |
(...skipping 12 matching lines...) Expand all Loading... | |
2381 reinterpret_cast<unsigned char*>(control_frame->data() + framed_data), | 2377 reinterpret_cast<unsigned char*>(control_frame->data() + framed_data), |
2382 to_read); | 2378 to_read); |
2383 unframed_data -= to_read; | 2379 unframed_data -= to_read; |
2384 framed_data += to_read; | 2380 framed_data += to_read; |
2385 } | 2381 } |
2386 EXPECT_EQ(0, visitor.error_count_); | 2382 EXPECT_EQ(0, visitor.error_count_); |
2387 EXPECT_EQ(settings.size() * 2, static_cast<unsigned>(visitor.setting_count_)); | 2383 EXPECT_EQ(settings.size() * 2, static_cast<unsigned>(visitor.setting_count_)); |
2388 EXPECT_EQ(2, visitor.settings_frame_count_); | 2384 EXPECT_EQ(2, visitor.settings_frame_count_); |
2389 } | 2385 } |
2390 | 2386 |
2391 // Tests handling of SETTINGS frame with duplicate entries. | |
2392 TEST_P(SpdyFramerTest, ReadDuplicateSettings) { | |
2393 SpdyFramer framer(spdy_version_); | |
2394 SpdySettings settings; | |
2395 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | |
2396 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); | |
2397 // This last setting should not be processed due to error above. | |
2398 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); | |
2399 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | |
2400 TestSpdyVisitor visitor(spdy_version_); | |
2401 visitor.use_compression_ = false; | |
2402 | |
2403 visitor.SimulateInFramer( | |
2404 reinterpret_cast<unsigned char*>(control_frame->data()), | |
2405 control_frame->length() + SpdyControlFrame::kHeaderSize); | |
2406 EXPECT_EQ(1, visitor.error_count_); | |
2407 EXPECT_EQ(1, visitor.setting_count_); | |
2408 EXPECT_EQ(1, visitor.settings_frame_count_); | |
2409 } | |
2410 | |
2411 // Tests handling of SETTINGS frame with entries out of order. | 2387 // Tests handling of SETTINGS frame with entries out of order. |
2412 TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { | 2388 TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { |
2413 SpdyFramer framer(spdy_version_); | 2389 SpdyFramer framer(spdy_version_); |
2414 SpdySettings settings; | 2390 SettingsMap settings; |
2415 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000002)); | 2391 SpdySettingsFlags flags = SETTINGS_FLAG_NONE; |
2416 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); | 2392 settings[SETTINGS_DOWNLOAD_BANDWIDTH] = |
2417 // This last setting should not be processed due to error above. | 2393 SettingsFlagsAndValue(flags, 0x00000002); |
2418 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); | 2394 settings[SETTINGS_UPLOAD_BANDWIDTH] = |
2395 SettingsFlagsAndValue(flags, 0x00000003); | |
2396 settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000003); | |
2419 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2397 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2420 TestSpdyVisitor visitor(spdy_version_); | 2398 TestSpdyVisitor visitor(spdy_version_); |
2421 visitor.use_compression_ = false; | 2399 visitor.use_compression_ = false; |
2422 | 2400 |
2423 visitor.SimulateInFramer( | 2401 visitor.SimulateInFramer( |
2424 reinterpret_cast<unsigned char*>(control_frame->data()), | 2402 reinterpret_cast<unsigned char*>(control_frame->data()), |
2425 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2403 control_frame->length() + SpdyControlFrame::kHeaderSize); |
2426 EXPECT_EQ(1, visitor.error_count_); | 2404 EXPECT_EQ(0, visitor.error_count_); |
Ryan Hamilton
2012/04/12 17:11:21
Why did the error_count change here?
ramant (doing other things)
2012/04/12 18:35:59
In the older version (in the list), if we had supp
Ryan Hamilton
2012/04/17 02:32:49
Sounds like it's invalid now. Nuke it?
ramant (doing other things)
2012/04/17 18:48:19
Done.
| |
2427 EXPECT_EQ(1, visitor.setting_count_); | 2405 EXPECT_EQ(settings.size(), static_cast<unsigned>(visitor.setting_count_)); |
2428 EXPECT_EQ(1, visitor.settings_frame_count_); | 2406 EXPECT_EQ(1, visitor.settings_frame_count_); |
2429 } | 2407 } |
2430 | 2408 |
2431 TEST_P(SpdyFramerTest, ReadCredentialFrame) { | 2409 TEST_P(SpdyFramerTest, ReadCredentialFrame) { |
2432 SpdyCredential credential; | 2410 SpdyCredential credential; |
2433 credential.slot = 3; | 2411 credential.slot = 3; |
2434 credential.proof = "proof"; | 2412 credential.proof = "proof"; |
2435 credential.certs.push_back("a cert"); | 2413 credential.certs.push_back("a cert"); |
2436 credential.certs.push_back("another cert"); | 2414 credential.certs.push_back("another cert"); |
2437 credential.certs.push_back("final cert"); | 2415 credential.certs.push_back("final cert"); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2697 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 2675 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
2698 | 2676 |
2699 SettingsFlagsAndId id_and_flags = | 2677 SettingsFlagsAndId id_and_flags = |
2700 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 2678 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
2701 EXPECT_EQ(kId, id_and_flags.id()); | 2679 EXPECT_EQ(kId, id_and_flags.id()); |
2702 EXPECT_EQ(kFlags, id_and_flags.flags()); | 2680 EXPECT_EQ(kFlags, id_and_flags.flags()); |
2703 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 2681 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
2704 } | 2682 } |
2705 | 2683 |
2706 } // namespace net | 2684 } // namespace net |
OLD | NEW |