| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 void StartServer() { | 402 void StartServer() { |
| 403 server_thread_.reset(new ServerThread( | 403 server_thread_.reset(new ServerThread( |
| 404 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), | 404 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), |
| 405 server_config_, server_supported_versions_), | 405 server_config_, server_supported_versions_), |
| 406 server_address_, strike_register_no_startup_period_)); | 406 server_address_, strike_register_no_startup_period_)); |
| 407 if (chlo_multiplier_ != 0) { | 407 if (chlo_multiplier_ != 0) { |
| 408 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); | 408 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); |
| 409 } | 409 } |
| 410 server_thread_->Initialize(); | 410 server_thread_->Initialize(); |
| 411 server_address_ = | 411 server_address_ = IPEndPoint(server_address_.address().bytes(), |
| 412 IPEndPoint(server_address_.address(), server_thread_->GetPort()); | 412 server_thread_->GetPort()); |
| 413 QuicDispatcher* dispatcher = | 413 QuicDispatcher* dispatcher = |
| 414 QuicServerPeer::GetDispatcher(server_thread_->server()); | 414 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 415 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); | 415 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); |
| 416 | 416 |
| 417 FLAGS_enable_quic_stateless_reject_support = | 417 FLAGS_enable_quic_stateless_reject_support = |
| 418 GetParam().server_uses_stateless_rejects_if_peer_supported; | 418 GetParam().server_uses_stateless_rejects_if_peer_supported; |
| 419 | 419 |
| 420 server_writer_->Initialize(QuicDispatcherPeer::GetHelper(dispatcher), | 420 server_writer_->Initialize(QuicDispatcherPeer::GetHelper(dispatcher), |
| 421 new ServerDelegate(dispatcher)); | 421 new ServerDelegate(dispatcher)); |
| 422 if (stream_factory_ != nullptr) { | 422 if (stream_factory_ != nullptr) { |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); | 1458 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); |
| 1459 self_address_ = IPEndPoint(ip, 0); | 1459 self_address_ = IPEndPoint(ip, 0); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 WriteResult WritePacket(const char* buffer, | 1462 WriteResult WritePacket(const char* buffer, |
| 1463 size_t buf_len, | 1463 size_t buf_len, |
| 1464 const IPAddressNumber& /*real_self_address*/, | 1464 const IPAddressNumber& /*real_self_address*/, |
| 1465 const IPEndPoint& peer_address) override { | 1465 const IPEndPoint& peer_address) override { |
| 1466 // Use wrong address! | 1466 // Use wrong address! |
| 1467 return QuicPacketWriterWrapper::WritePacket( | 1467 return QuicPacketWriterWrapper::WritePacket( |
| 1468 buffer, buf_len, self_address_.address(), peer_address); | 1468 buffer, buf_len, self_address_.address().bytes(), peer_address); |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 bool IsWriteBlockedDataBuffered() const override { return false; } | 1471 bool IsWriteBlockedDataBuffered() const override { return false; } |
| 1472 | 1472 |
| 1473 IPEndPoint self_address_; | 1473 IPEndPoint self_address_; |
| 1474 }; | 1474 }; |
| 1475 | 1475 |
| 1476 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { | 1476 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { |
| 1477 ASSERT_TRUE(Initialize()); | 1477 ASSERT_TRUE(Initialize()); |
| 1478 | 1478 |
| 1479 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1479 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1480 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1480 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1481 | 1481 |
| 1482 // Store the client IP address which was used to send the first request. | 1482 // Store the client IP address which was used to send the first request. |
| 1483 IPAddressNumber old_host = client_->client()->client_address().address(); | 1483 IPAddressNumber old_host = |
| 1484 client_->client()->client_address().address().bytes(); |
| 1484 | 1485 |
| 1485 // Migrate socket to the new IP address. | 1486 // Migrate socket to the new IP address. |
| 1486 IPAddressNumber new_host; | 1487 IPAddressNumber new_host; |
| 1487 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &new_host)); | 1488 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &new_host)); |
| 1488 EXPECT_NE(old_host, new_host); | 1489 EXPECT_NE(old_host, new_host); |
| 1489 ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); | 1490 ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); |
| 1490 | 1491 |
| 1491 // Send a request using the new socket. | 1492 // Send a request using the new socket. |
| 1492 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1493 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 1493 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1494 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1517 // The packet writer needs to be updated to use the new FD. | 1518 // The packet writer needs to be updated to use the new FD. |
| 1518 client_->client()->CreateQuicPacketWriter(); | 1519 client_->client()->CreateQuicPacketWriter(); |
| 1519 | 1520 |
| 1520 // Change the internal state of the client and connection to use the new port, | 1521 // Change the internal state of the client and connection to use the new port, |
| 1521 // this is done because in a real NAT rebinding the client wouldn't see any | 1522 // this is done because in a real NAT rebinding the client wouldn't see any |
| 1522 // port change, and so expects no change to incoming port. | 1523 // port change, and so expects no change to incoming port. |
| 1523 // This is kind of ugly, but needed as we are simply swapping out the client | 1524 // This is kind of ugly, but needed as we are simply swapping out the client |
| 1524 // FD rather than any more complex NAT rebinding simulation. | 1525 // FD rather than any more complex NAT rebinding simulation. |
| 1525 int new_port = client_->client()->client_address().port(); | 1526 int new_port = client_->client()->client_address().port(); |
| 1526 QuicClientPeer::SetClientPort(client_->client(), new_port); | 1527 QuicClientPeer::SetClientPort(client_->client(), new_port); |
| 1527 QuicConnectionPeer::SetSelfAddress( | 1528 QuicConnectionPeer::SetSelfAddress(client_->client()->session()->connection(), |
| 1528 client_->client()->session()->connection(), | 1529 IPEndPoint(client_->client() |
| 1529 IPEndPoint( | 1530 ->session() |
| 1530 client_->client()->session()->connection()->self_address().address(), | 1531 ->connection() |
| 1531 new_port)); | 1532 ->self_address() |
| 1533 .address() |
| 1534 .bytes(), |
| 1535 new_port)); |
| 1532 | 1536 |
| 1533 // Register the new FD for epoll events. | 1537 // Register the new FD for epoll events. |
| 1534 int new_fd = client_->client()->fd(); | 1538 int new_fd = client_->client()->fd(); |
| 1535 eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); | 1539 eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); |
| 1536 | 1540 |
| 1537 // Send a second request, using the new FD. | 1541 // Send a second request, using the new FD. |
| 1538 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1542 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 1539 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1543 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1540 | 1544 |
| 1541 // Verify that the client's ephemeral port is different. | 1545 // Verify that the client's ephemeral port is different. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 Perspective::IS_SERVER); | 1801 Perspective::IS_SERVER); |
| 1798 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); | 1802 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); |
| 1799 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1803 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
| 1800 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1804 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
| 1801 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1805 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
| 1802 .Times(1); | 1806 .Times(1); |
| 1803 // We must pause the server's thread in order to call WritePacket without | 1807 // We must pause the server's thread in order to call WritePacket without |
| 1804 // race conditions. | 1808 // race conditions. |
| 1805 server_thread_->Pause(); | 1809 server_thread_->Pause(); |
| 1806 server_writer_->WritePacket(packet->data(), packet->length(), | 1810 server_writer_->WritePacket(packet->data(), packet->length(), |
| 1807 server_address_.address(), | 1811 server_address_.address().bytes(), |
| 1808 client_->client()->client_address()); | 1812 client_->client()->client_address()); |
| 1809 server_thread_->Resume(); | 1813 server_thread_->Resume(); |
| 1810 | 1814 |
| 1811 // The connection should be unaffected. | 1815 // The connection should be unaffected. |
| 1812 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1816 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1813 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1817 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1814 | 1818 |
| 1815 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1819 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
| 1816 } | 1820 } |
| 1817 | 1821 |
| 1818 // Send a public reset from the client for a different connection ID. | 1822 // Send a public reset from the client for a different connection ID. |
| 1819 // It should be ignored. | 1823 // It should be ignored. |
| 1820 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { | 1824 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { |
| 1821 ASSERT_TRUE(Initialize()); | 1825 ASSERT_TRUE(Initialize()); |
| 1822 | 1826 |
| 1823 // Send the public reset. | 1827 // Send the public reset. |
| 1824 QuicConnectionId incorrect_connection_id = | 1828 QuicConnectionId incorrect_connection_id = |
| 1825 client_->client()->session()->connection()->connection_id() + 1; | 1829 client_->client()->session()->connection()->connection_id() + 1; |
| 1826 QuicPublicResetPacket header; | 1830 QuicPublicResetPacket header; |
| 1827 header.public_header.connection_id = incorrect_connection_id; | 1831 header.public_header.connection_id = incorrect_connection_id; |
| 1828 header.public_header.reset_flag = true; | 1832 header.public_header.reset_flag = true; |
| 1829 header.public_header.version_flag = false; | 1833 header.public_header.version_flag = false; |
| 1830 header.rejected_packet_number = 10101; | 1834 header.rejected_packet_number = 10101; |
| 1831 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 1835 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 1832 Perspective::IS_CLIENT); | 1836 Perspective::IS_CLIENT); |
| 1833 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); | 1837 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); |
| 1834 client_writer_->WritePacket(packet->data(), packet->length(), | 1838 client_writer_->WritePacket( |
| 1835 client_->client()->client_address().address(), | 1839 packet->data(), packet->length(), |
| 1836 server_address_); | 1840 client_->client()->client_address().address().bytes(), server_address_); |
| 1837 | 1841 |
| 1838 // The connection should be unaffected. | 1842 // The connection should be unaffected. |
| 1839 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1843 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1840 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1844 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1841 } | 1845 } |
| 1842 | 1846 |
| 1843 // Send a version negotiation packet from the server for a different | 1847 // Send a version negotiation packet from the server for a different |
| 1844 // connection ID. It should be ignored. | 1848 // connection ID. It should be ignored. |
| 1845 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { | 1849 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { |
| 1846 ASSERT_TRUE(Initialize()); | 1850 ASSERT_TRUE(Initialize()); |
| 1847 | 1851 |
| 1848 // Send the version negotiation packet. | 1852 // Send the version negotiation packet. |
| 1849 QuicConnectionId incorrect_connection_id = | 1853 QuicConnectionId incorrect_connection_id = |
| 1850 client_->client()->session()->connection()->connection_id() + 1; | 1854 client_->client()->session()->connection()->connection_id() + 1; |
| 1851 scoped_ptr<QuicEncryptedPacket> packet( | 1855 scoped_ptr<QuicEncryptedPacket> packet( |
| 1852 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, | 1856 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, |
| 1853 server_supported_versions_)); | 1857 server_supported_versions_)); |
| 1854 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1858 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
| 1855 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1859 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
| 1856 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1860 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
| 1857 .Times(1); | 1861 .Times(1); |
| 1858 // We must pause the server's thread in order to call WritePacket without | 1862 // We must pause the server's thread in order to call WritePacket without |
| 1859 // race conditions. | 1863 // race conditions. |
| 1860 server_thread_->Pause(); | 1864 server_thread_->Pause(); |
| 1861 server_writer_->WritePacket(packet->data(), packet->length(), | 1865 server_writer_->WritePacket(packet->data(), packet->length(), |
| 1862 server_address_.address(), | 1866 server_address_.address().bytes(), |
| 1863 client_->client()->client_address()); | 1867 client_->client()->client_address()); |
| 1864 server_thread_->Resume(); | 1868 server_thread_->Resume(); |
| 1865 | 1869 |
| 1866 // The connection should be unaffected. | 1870 // The connection should be unaffected. |
| 1867 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1871 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1868 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1872 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1869 | 1873 |
| 1870 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1874 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
| 1871 } | 1875 } |
| 1872 | 1876 |
| 1873 // A bad header shouldn't tear down the connection, because the receiver can't | 1877 // A bad header shouldn't tear down the connection, because the receiver can't |
| 1874 // tell the connection ID. | 1878 // tell the connection ID. |
| 1875 TEST_P(EndToEndTest, BadPacketHeaderTruncated) { | 1879 TEST_P(EndToEndTest, BadPacketHeaderTruncated) { |
| 1876 ASSERT_TRUE(Initialize()); | 1880 ASSERT_TRUE(Initialize()); |
| 1877 | 1881 |
| 1878 // Start the connection. | 1882 // Start the connection. |
| 1879 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1883 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1880 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1884 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1881 | 1885 |
| 1882 // Packet with invalid public flags. | 1886 // Packet with invalid public flags. |
| 1883 char packet[] = {// public flags (8 byte connection_id) | 1887 char packet[] = {// public flags (8 byte connection_id) |
| 1884 0x3C, | 1888 0x3C, |
| 1885 // truncated connection ID | 1889 // truncated connection ID |
| 1886 0x11}; | 1890 0x11}; |
| 1887 client_writer_->WritePacket(&packet[0], sizeof(packet), | 1891 client_writer_->WritePacket( |
| 1888 client_->client()->client_address().address(), | 1892 &packet[0], sizeof(packet), |
| 1889 server_address_); | 1893 client_->client()->client_address().address().bytes(), server_address_); |
| 1890 // Give the server time to process the packet. | 1894 // Give the server time to process the packet. |
| 1891 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1895 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1892 // Pause the server so we can access the server's internals without races. | 1896 // Pause the server so we can access the server's internals without races. |
| 1893 server_thread_->Pause(); | 1897 server_thread_->Pause(); |
| 1894 QuicDispatcher* dispatcher = | 1898 QuicDispatcher* dispatcher = |
| 1895 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1899 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1896 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, | 1900 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, |
| 1897 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1901 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| 1898 server_thread_->Resume(); | 1902 server_thread_->Resume(); |
| 1899 | 1903 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1915 char packet[] = { | 1919 char packet[] = { |
| 1916 // invalid public flags | 1920 // invalid public flags |
| 1917 0xFF, | 1921 0xFF, |
| 1918 // connection_id | 1922 // connection_id |
| 1919 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 1923 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1920 // packet sequence number | 1924 // packet sequence number |
| 1921 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 1925 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
| 1922 // private flags | 1926 // private flags |
| 1923 0x00, | 1927 0x00, |
| 1924 }; | 1928 }; |
| 1925 client_writer_->WritePacket(&packet[0], sizeof(packet), | 1929 client_writer_->WritePacket( |
| 1926 client_->client()->client_address().address(), | 1930 &packet[0], sizeof(packet), |
| 1927 server_address_); | 1931 client_->client()->client_address().address().bytes(), server_address_); |
| 1928 // Give the server time to process the packet. | 1932 // Give the server time to process the packet. |
| 1929 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1933 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1930 // Pause the server so we can access the server's internals without races. | 1934 // Pause the server so we can access the server's internals without races. |
| 1931 server_thread_->Pause(); | 1935 server_thread_->Pause(); |
| 1932 QuicDispatcher* dispatcher = | 1936 QuicDispatcher* dispatcher = |
| 1933 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1937 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1934 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, | 1938 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, |
| 1935 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1939 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| 1936 server_thread_->Resume(); | 1940 server_thread_->Resume(); |
| 1937 | 1941 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1950 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1954 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1951 | 1955 |
| 1952 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 1956 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
| 1953 client_->client()->session()->connection()->connection_id(), false, false, | 1957 client_->client()->session()->connection()->connection_id(), false, false, |
| 1954 1, "At least 20 characters.", PACKET_8BYTE_CONNECTION_ID, | 1958 1, "At least 20 characters.", PACKET_8BYTE_CONNECTION_ID, |
| 1955 PACKET_6BYTE_PACKET_NUMBER)); | 1959 PACKET_6BYTE_PACKET_NUMBER)); |
| 1956 // Damage the encrypted data. | 1960 // Damage the encrypted data. |
| 1957 string damaged_packet(packet->data(), packet->length()); | 1961 string damaged_packet(packet->data(), packet->length()); |
| 1958 damaged_packet[30] ^= 0x01; | 1962 damaged_packet[30] ^= 0x01; |
| 1959 DVLOG(1) << "Sending bad packet."; | 1963 DVLOG(1) << "Sending bad packet."; |
| 1960 client_writer_->WritePacket(damaged_packet.data(), damaged_packet.length(), | 1964 client_writer_->WritePacket( |
| 1961 client_->client()->client_address().address(), | 1965 damaged_packet.data(), damaged_packet.length(), |
| 1962 server_address_); | 1966 client_->client()->client_address().address().bytes(), server_address_); |
| 1963 // Give the server time to process the packet. | 1967 // Give the server time to process the packet. |
| 1964 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1968 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1965 // This error is sent to the connection's OnError (which ignores it), so the | 1969 // This error is sent to the connection's OnError (which ignores it), so the |
| 1966 // dispatcher doesn't see it. | 1970 // dispatcher doesn't see it. |
| 1967 // Pause the server so we can access the server's internals without races. | 1971 // Pause the server so we can access the server's internals without races. |
| 1968 server_thread_->Pause(); | 1972 server_thread_->Pause(); |
| 1969 QuicDispatcher* dispatcher = | 1973 QuicDispatcher* dispatcher = |
| 1970 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1974 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1971 EXPECT_EQ(QUIC_NO_ERROR, | 1975 EXPECT_EQ(QUIC_NO_ERROR, |
| 1972 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1976 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 | 2167 |
| 2164 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); | 2168 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); |
| 2165 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 2169 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 2166 EXPECT_EQ(trailers, client_->response_trailers()); | 2170 EXPECT_EQ(trailers, client_->response_trailers()); |
| 2167 } | 2171 } |
| 2168 | 2172 |
| 2169 } // namespace | 2173 } // namespace |
| 2170 } // namespace test | 2174 } // namespace test |
| 2171 } // namespace tools | 2175 } // namespace tools |
| 2172 } // namespace net | 2176 } // namespace net |
| OLD | NEW |