| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 void StartServer() { | 403 void StartServer() { |
| 404 server_thread_.reset(new ServerThread( | 404 server_thread_.reset(new ServerThread( |
| 405 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), | 405 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), |
| 406 server_config_, server_supported_versions_), | 406 server_config_, server_supported_versions_), |
| 407 server_address_, strike_register_no_startup_period_)); | 407 server_address_, strike_register_no_startup_period_)); |
| 408 if (chlo_multiplier_ != 0) { | 408 if (chlo_multiplier_ != 0) { |
| 409 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); | 409 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); |
| 410 } | 410 } |
| 411 server_thread_->Initialize(); | 411 server_thread_->Initialize(); |
| 412 server_address_ = | 412 server_address_ = |
| 413 IPEndPoint(server_address_.address(), server_thread_->GetPort()); | 413 IPEndPoint(server_address_.address_number(), server_thread_->GetPort()); |
| 414 QuicDispatcher* dispatcher = | 414 QuicDispatcher* dispatcher = |
| 415 QuicServerPeer::GetDispatcher(server_thread_->server()); | 415 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 416 TestWriterFactory* packet_writer_factory = new TestWriterFactory(); | 416 TestWriterFactory* packet_writer_factory = new TestWriterFactory(); |
| 417 QuicDispatcherPeer::SetPacketWriterFactory(dispatcher, | 417 QuicDispatcherPeer::SetPacketWriterFactory(dispatcher, |
| 418 packet_writer_factory); | 418 packet_writer_factory); |
| 419 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); | 419 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); |
| 420 | 420 |
| 421 FLAGS_enable_quic_stateless_reject_support = | 421 FLAGS_enable_quic_stateless_reject_support = |
| 422 GetParam().server_uses_stateless_rejects_if_peer_supported; | 422 GetParam().server_uses_stateless_rejects_if_peer_supported; |
| 423 | 423 |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); | 1444 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); |
| 1445 self_address_ = IPEndPoint(ip, 0); | 1445 self_address_ = IPEndPoint(ip, 0); |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 WriteResult WritePacket(const char* buffer, | 1448 WriteResult WritePacket(const char* buffer, |
| 1449 size_t buf_len, | 1449 size_t buf_len, |
| 1450 const IPAddressNumber& /*real_self_address*/, | 1450 const IPAddressNumber& /*real_self_address*/, |
| 1451 const IPEndPoint& peer_address) override { | 1451 const IPEndPoint& peer_address) override { |
| 1452 // Use wrong address! | 1452 // Use wrong address! |
| 1453 return QuicPacketWriterWrapper::WritePacket( | 1453 return QuicPacketWriterWrapper::WritePacket( |
| 1454 buffer, buf_len, self_address_.address(), peer_address); | 1454 buffer, buf_len, self_address_.address_number(), peer_address); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 bool IsWriteBlockedDataBuffered() const override { return false; } | 1457 bool IsWriteBlockedDataBuffered() const override { return false; } |
| 1458 | 1458 |
| 1459 IPEndPoint self_address_; | 1459 IPEndPoint self_address_; |
| 1460 }; | 1460 }; |
| 1461 | 1461 |
| 1462 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { | 1462 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { |
| 1463 ASSERT_TRUE(Initialize()); | 1463 ASSERT_TRUE(Initialize()); |
| 1464 | 1464 |
| 1465 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1465 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1466 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1466 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1467 | 1467 |
| 1468 // Store the client IP address which was used to send the first request. | 1468 // Store the client IP address which was used to send the first request. |
| 1469 IPAddressNumber old_host = client_->client()->client_address().address(); | 1469 IPAddressNumber old_host = |
| 1470 client_->client()->client_address().address_number(); |
| 1470 | 1471 |
| 1471 // Migrate socket to the new IP address. | 1472 // Migrate socket to the new IP address. |
| 1472 IPAddressNumber new_host; | 1473 IPAddressNumber new_host; |
| 1473 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &new_host)); | 1474 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &new_host)); |
| 1474 EXPECT_NE(old_host, new_host); | 1475 EXPECT_NE(old_host, new_host); |
| 1475 ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); | 1476 ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); |
| 1476 | 1477 |
| 1477 // Send a request using the new socket. | 1478 // Send a request using the new socket. |
| 1478 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1479 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 1479 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1480 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1503 // The packet writer needs to be updated to use the new FD. | 1504 // The packet writer needs to be updated to use the new FD. |
| 1504 client_->client()->CreateQuicPacketWriter(); | 1505 client_->client()->CreateQuicPacketWriter(); |
| 1505 | 1506 |
| 1506 // Change the internal state of the client and connection to use the new port, | 1507 // Change the internal state of the client and connection to use the new port, |
| 1507 // this is done because in a real NAT rebinding the client wouldn't see any | 1508 // this is done because in a real NAT rebinding the client wouldn't see any |
| 1508 // port change, and so expects no change to incoming port. | 1509 // port change, and so expects no change to incoming port. |
| 1509 // This is kind of ugly, but needed as we are simply swapping out the client | 1510 // This is kind of ugly, but needed as we are simply swapping out the client |
| 1510 // FD rather than any more complex NAT rebinding simulation. | 1511 // FD rather than any more complex NAT rebinding simulation. |
| 1511 int new_port = client_->client()->client_address().port(); | 1512 int new_port = client_->client()->client_address().port(); |
| 1512 QuicClientPeer::SetClientPort(client_->client(), new_port); | 1513 QuicClientPeer::SetClientPort(client_->client(), new_port); |
| 1513 QuicConnectionPeer::SetSelfAddress( | 1514 QuicConnectionPeer::SetSelfAddress(client_->client()->session()->connection(), |
| 1514 client_->client()->session()->connection(), | 1515 IPEndPoint(client_->client() |
| 1515 IPEndPoint( | 1516 ->session() |
| 1516 client_->client()->session()->connection()->self_address().address(), | 1517 ->connection() |
| 1517 new_port)); | 1518 ->self_address() |
| 1519 .address_number(), |
| 1520 new_port)); |
| 1518 | 1521 |
| 1519 // Register the new FD for epoll events. | 1522 // Register the new FD for epoll events. |
| 1520 int new_fd = client_->client()->fd(); | 1523 int new_fd = client_->client()->fd(); |
| 1521 eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); | 1524 eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); |
| 1522 | 1525 |
| 1523 // Send a second request, using the new FD. | 1526 // Send a second request, using the new FD. |
| 1524 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 1527 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 1525 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1528 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1526 | 1529 |
| 1527 // Verify that the client's ephemeral port is different. | 1530 // Verify that the client's ephemeral port is different. |
| 1528 IPEndPoint new_address = client_->client()->client_address(); | 1531 IPEndPoint new_address = client_->client()->client_address(); |
| 1529 EXPECT_EQ(old_address.address(), new_address.address()); | 1532 EXPECT_EQ(old_address.address_number(), new_address.address_number()); |
| 1530 EXPECT_NE(old_address.port(), new_address.port()); | 1533 EXPECT_NE(old_address.port(), new_address.port()); |
| 1531 } | 1534 } |
| 1532 | 1535 |
| 1533 TEST_P(EndToEndTest, DifferentFlowControlWindows) { | 1536 TEST_P(EndToEndTest, DifferentFlowControlWindows) { |
| 1534 // Client and server can set different initial flow control receive windows. | 1537 // Client and server can set different initial flow control receive windows. |
| 1535 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly | 1538 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly |
| 1536 // in the crypto handshake. | 1539 // in the crypto handshake. |
| 1537 const uint32_t kClientStreamIFCW = 123456; | 1540 const uint32_t kClientStreamIFCW = 123456; |
| 1538 const uint32_t kClientSessionIFCW = 234567; | 1541 const uint32_t kClientSessionIFCW = 234567; |
| 1539 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); | 1542 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 Perspective::IS_SERVER); | 1786 Perspective::IS_SERVER); |
| 1784 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); | 1787 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); |
| 1785 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1788 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
| 1786 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1789 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
| 1787 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1790 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
| 1788 .Times(1); | 1791 .Times(1); |
| 1789 // We must pause the server's thread in order to call WritePacket without | 1792 // We must pause the server's thread in order to call WritePacket without |
| 1790 // race conditions. | 1793 // race conditions. |
| 1791 server_thread_->Pause(); | 1794 server_thread_->Pause(); |
| 1792 server_writer_->WritePacket(packet->data(), packet->length(), | 1795 server_writer_->WritePacket(packet->data(), packet->length(), |
| 1793 server_address_.address(), | 1796 server_address_.address_number(), |
| 1794 client_->client()->client_address()); | 1797 client_->client()->client_address()); |
| 1795 server_thread_->Resume(); | 1798 server_thread_->Resume(); |
| 1796 | 1799 |
| 1797 // The connection should be unaffected. | 1800 // The connection should be unaffected. |
| 1798 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1801 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1799 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1802 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1800 | 1803 |
| 1801 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1804 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
| 1802 } | 1805 } |
| 1803 | 1806 |
| 1804 // Send a public reset from the client for a different connection ID. | 1807 // Send a public reset from the client for a different connection ID. |
| 1805 // It should be ignored. | 1808 // It should be ignored. |
| 1806 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { | 1809 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { |
| 1807 ASSERT_TRUE(Initialize()); | 1810 ASSERT_TRUE(Initialize()); |
| 1808 | 1811 |
| 1809 // Send the public reset. | 1812 // Send the public reset. |
| 1810 QuicConnectionId incorrect_connection_id = | 1813 QuicConnectionId incorrect_connection_id = |
| 1811 client_->client()->session()->connection()->connection_id() + 1; | 1814 client_->client()->session()->connection()->connection_id() + 1; |
| 1812 QuicPublicResetPacket header; | 1815 QuicPublicResetPacket header; |
| 1813 header.public_header.connection_id = incorrect_connection_id; | 1816 header.public_header.connection_id = incorrect_connection_id; |
| 1814 header.public_header.reset_flag = true; | 1817 header.public_header.reset_flag = true; |
| 1815 header.public_header.version_flag = false; | 1818 header.public_header.version_flag = false; |
| 1816 header.rejected_packet_number = 10101; | 1819 header.rejected_packet_number = 10101; |
| 1817 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 1820 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 1818 Perspective::IS_CLIENT); | 1821 Perspective::IS_CLIENT); |
| 1819 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); | 1822 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); |
| 1820 client_writer_->WritePacket(packet->data(), packet->length(), | 1823 client_writer_->WritePacket( |
| 1821 client_->client()->client_address().address(), | 1824 packet->data(), packet->length(), |
| 1822 server_address_); | 1825 client_->client()->client_address().address_number(), server_address_); |
| 1823 | 1826 |
| 1824 // The connection should be unaffected. | 1827 // The connection should be unaffected. |
| 1825 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1828 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1826 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1829 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1827 } | 1830 } |
| 1828 | 1831 |
| 1829 // Send a version negotiation packet from the server for a different | 1832 // Send a version negotiation packet from the server for a different |
| 1830 // connection ID. It should be ignored. | 1833 // connection ID. It should be ignored. |
| 1831 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { | 1834 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { |
| 1832 ASSERT_TRUE(Initialize()); | 1835 ASSERT_TRUE(Initialize()); |
| 1833 | 1836 |
| 1834 // Send the version negotiation packet. | 1837 // Send the version negotiation packet. |
| 1835 QuicConnectionId incorrect_connection_id = | 1838 QuicConnectionId incorrect_connection_id = |
| 1836 client_->client()->session()->connection()->connection_id() + 1; | 1839 client_->client()->session()->connection()->connection_id() + 1; |
| 1837 scoped_ptr<QuicEncryptedPacket> packet( | 1840 scoped_ptr<QuicEncryptedPacket> packet( |
| 1838 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, | 1841 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, |
| 1839 server_supported_versions_)); | 1842 server_supported_versions_)); |
| 1840 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 1843 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
| 1841 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 1844 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
| 1842 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 1845 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
| 1843 .Times(1); | 1846 .Times(1); |
| 1844 // We must pause the server's thread in order to call WritePacket without | 1847 // We must pause the server's thread in order to call WritePacket without |
| 1845 // race conditions. | 1848 // race conditions. |
| 1846 server_thread_->Pause(); | 1849 server_thread_->Pause(); |
| 1847 server_writer_->WritePacket(packet->data(), packet->length(), | 1850 server_writer_->WritePacket(packet->data(), packet->length(), |
| 1848 server_address_.address(), | 1851 server_address_.address_number(), |
| 1849 client_->client()->client_address()); | 1852 client_->client()->client_address()); |
| 1850 server_thread_->Resume(); | 1853 server_thread_->Resume(); |
| 1851 | 1854 |
| 1852 // The connection should be unaffected. | 1855 // The connection should be unaffected. |
| 1853 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1856 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1854 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1857 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1855 | 1858 |
| 1856 client_->client()->session()->connection()->set_debug_visitor(nullptr); | 1859 client_->client()->session()->connection()->set_debug_visitor(nullptr); |
| 1857 } | 1860 } |
| 1858 | 1861 |
| 1859 // A bad header shouldn't tear down the connection, because the receiver can't | 1862 // A bad header shouldn't tear down the connection, because the receiver can't |
| 1860 // tell the connection ID. | 1863 // tell the connection ID. |
| 1861 TEST_P(EndToEndTest, BadPacketHeaderTruncated) { | 1864 TEST_P(EndToEndTest, BadPacketHeaderTruncated) { |
| 1862 ASSERT_TRUE(Initialize()); | 1865 ASSERT_TRUE(Initialize()); |
| 1863 | 1866 |
| 1864 // Start the connection. | 1867 // Start the connection. |
| 1865 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 1868 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 1866 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1869 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1867 | 1870 |
| 1868 // Packet with invalid public flags. | 1871 // Packet with invalid public flags. |
| 1869 char packet[] = {// public flags (8 byte connection_id) | 1872 char packet[] = {// public flags (8 byte connection_id) |
| 1870 0x3C, | 1873 0x3C, |
| 1871 // truncated connection ID | 1874 // truncated connection ID |
| 1872 0x11}; | 1875 0x11}; |
| 1873 client_writer_->WritePacket(&packet[0], sizeof(packet), | 1876 client_writer_->WritePacket( |
| 1874 client_->client()->client_address().address(), | 1877 &packet[0], sizeof(packet), |
| 1875 server_address_); | 1878 client_->client()->client_address().address_number(), server_address_); |
| 1876 // Give the server time to process the packet. | 1879 // Give the server time to process the packet. |
| 1877 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1880 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1878 // Pause the server so we can access the server's internals without races. | 1881 // Pause the server so we can access the server's internals without races. |
| 1879 server_thread_->Pause(); | 1882 server_thread_->Pause(); |
| 1880 QuicDispatcher* dispatcher = | 1883 QuicDispatcher* dispatcher = |
| 1881 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1884 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1882 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, | 1885 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, |
| 1883 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1886 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| 1884 server_thread_->Resume(); | 1887 server_thread_->Resume(); |
| 1885 | 1888 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1901 char packet[] = { | 1904 char packet[] = { |
| 1902 // invalid public flags | 1905 // invalid public flags |
| 1903 0xFF, | 1906 0xFF, |
| 1904 // connection_id | 1907 // connection_id |
| 1905 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 1908 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1906 // packet sequence number | 1909 // packet sequence number |
| 1907 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 1910 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
| 1908 // private flags | 1911 // private flags |
| 1909 0x00, | 1912 0x00, |
| 1910 }; | 1913 }; |
| 1911 client_writer_->WritePacket(&packet[0], sizeof(packet), | 1914 client_writer_->WritePacket( |
| 1912 client_->client()->client_address().address(), | 1915 &packet[0], sizeof(packet), |
| 1913 server_address_); | 1916 client_->client()->client_address().address_number(), server_address_); |
| 1914 // Give the server time to process the packet. | 1917 // Give the server time to process the packet. |
| 1915 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1918 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1916 // Pause the server so we can access the server's internals without races. | 1919 // Pause the server so we can access the server's internals without races. |
| 1917 server_thread_->Pause(); | 1920 server_thread_->Pause(); |
| 1918 QuicDispatcher* dispatcher = | 1921 QuicDispatcher* dispatcher = |
| 1919 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1922 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1920 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, | 1923 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, |
| 1921 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1924 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| 1922 server_thread_->Resume(); | 1925 server_thread_->Resume(); |
| 1923 | 1926 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1936 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 1939 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 1937 | 1940 |
| 1938 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 1941 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
| 1939 client_->client()->session()->connection()->connection_id(), false, false, | 1942 client_->client()->session()->connection()->connection_id(), false, false, |
| 1940 1, "At least 20 characters.", PACKET_8BYTE_CONNECTION_ID, | 1943 1, "At least 20 characters.", PACKET_8BYTE_CONNECTION_ID, |
| 1941 PACKET_6BYTE_PACKET_NUMBER)); | 1944 PACKET_6BYTE_PACKET_NUMBER)); |
| 1942 // Damage the encrypted data. | 1945 // Damage the encrypted data. |
| 1943 string damaged_packet(packet->data(), packet->length()); | 1946 string damaged_packet(packet->data(), packet->length()); |
| 1944 damaged_packet[30] ^= 0x01; | 1947 damaged_packet[30] ^= 0x01; |
| 1945 DVLOG(1) << "Sending bad packet."; | 1948 DVLOG(1) << "Sending bad packet."; |
| 1946 client_writer_->WritePacket(damaged_packet.data(), damaged_packet.length(), | 1949 client_writer_->WritePacket( |
| 1947 client_->client()->client_address().address(), | 1950 damaged_packet.data(), damaged_packet.length(), |
| 1948 server_address_); | 1951 client_->client()->client_address().address_number(), server_address_); |
| 1949 // Give the server time to process the packet. | 1952 // Give the server time to process the packet. |
| 1950 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 1953 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 1951 // This error is sent to the connection's OnError (which ignores it), so the | 1954 // This error is sent to the connection's OnError (which ignores it), so the |
| 1952 // dispatcher doesn't see it. | 1955 // dispatcher doesn't see it. |
| 1953 // Pause the server so we can access the server's internals without races. | 1956 // Pause the server so we can access the server's internals without races. |
| 1954 server_thread_->Pause(); | 1957 server_thread_->Pause(); |
| 1955 QuicDispatcher* dispatcher = | 1958 QuicDispatcher* dispatcher = |
| 1956 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1959 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1957 EXPECT_EQ(QUIC_NO_ERROR, | 1960 EXPECT_EQ(QUIC_NO_ERROR, |
| 1958 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); | 1961 QuicDispatcherPeer::GetAndClearLastError(dispatcher)); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 | 2152 |
| 2150 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); | 2153 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); |
| 2151 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 2154 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 2152 EXPECT_EQ(trailers, client_->response_trailers()); | 2155 EXPECT_EQ(trailers, client_->response_trailers()); |
| 2153 } | 2156 } |
| 2154 | 2157 |
| 2155 } // namespace | 2158 } // namespace |
| 2156 } // namespace test | 2159 } // namespace test |
| 2157 } // namespace tools | 2160 } // namespace tools |
| 2158 } // namespace net | 2161 } // namespace net |
| OLD | NEW |