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 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 // Pause the server to avoid races. | 1764 // Pause the server to avoid races. |
1765 server_thread_->Pause(); | 1765 server_thread_->Pause(); |
1766 // Make sure the delegate does get the notification it expects. | 1766 // Make sure the delegate does get the notification it expects. |
1767 while (!delegate->has_been_notified()) { | 1767 while (!delegate->has_been_notified()) { |
1768 // Waits for up to 50 ms. | 1768 // Waits for up to 50 ms. |
1769 client_->client()->WaitForEvents(); | 1769 client_->client()->WaitForEvents(); |
1770 } | 1770 } |
1771 server_thread_->Resume(); | 1771 server_thread_->Resume(); |
1772 } | 1772 } |
1773 | 1773 |
| 1774 // Send a public reset from the server. |
| 1775 TEST_P(EndToEndTest, ServerSendPublicReset) { |
| 1776 ASSERT_TRUE(Initialize()); |
| 1777 |
| 1778 // Send the public reset. |
| 1779 QuicConnectionId connection_id = |
| 1780 client_->client()->session()->connection()->connection_id(); |
| 1781 QuicPublicResetPacket header; |
| 1782 header.public_header.connection_id = connection_id; |
| 1783 header.public_header.reset_flag = true; |
| 1784 header.public_header.version_flag = false; |
| 1785 header.rejected_packet_number = 10101; |
| 1786 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 1787 Perspective::IS_SERVER); |
| 1788 std::unique_ptr<QuicEncryptedPacket> packet( |
| 1789 framer.BuildPublicResetPacket(header)); |
| 1790 // We must pause the server's thread in order to call WritePacket without |
| 1791 // race conditions. |
| 1792 server_thread_->Pause(); |
| 1793 server_writer_->WritePacket( |
| 1794 packet->data(), packet->length(), server_address_.address(), |
| 1795 client_->client()->GetLatestClientAddress(), nullptr); |
| 1796 server_thread_->Resume(); |
| 1797 |
| 1798 // The request should fail. |
| 1799 EXPECT_EQ("", client_->SendSynchronousRequest("/foo")); |
| 1800 EXPECT_EQ(0u, client_->response_headers()->parsed_response_code()); |
| 1801 EXPECT_EQ(QUIC_PUBLIC_RESET, client_->connection_error()); |
| 1802 } |
| 1803 |
1774 // Send a public reset from the server for a different connection ID. | 1804 // Send a public reset from the server for a different connection ID. |
1775 // It should be ignored. | 1805 // It should be ignored. |
1776 TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) { | 1806 TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) { |
1777 ASSERT_TRUE(Initialize()); | 1807 ASSERT_TRUE(Initialize()); |
1778 | 1808 |
1779 // Send the public reset. | 1809 // Send the public reset. |
1780 QuicConnectionId incorrect_connection_id = | 1810 QuicConnectionId incorrect_connection_id = |
1781 client_->client()->session()->connection()->connection_id() + 1; | 1811 client_->client()->session()->connection()->connection_id() + 1; |
1782 QuicPublicResetPacket header; | 1812 QuicPublicResetPacket header; |
1783 header.public_header.connection_id = incorrect_connection_id; | 1813 header.public_header.connection_id = incorrect_connection_id; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 client_->WaitForResponse(); | 2725 client_->WaitForResponse(); |
2696 // TODO(fayang): Fix this test to work with stateless rejects. | 2726 // TODO(fayang): Fix this test to work with stateless rejects. |
2697 if (!BothSidesSupportStatelessRejects()) { | 2727 if (!BothSidesSupportStatelessRejects()) { |
2698 VerifyCleanConnection(false); | 2728 VerifyCleanConnection(false); |
2699 } | 2729 } |
2700 } | 2730 } |
2701 | 2731 |
2702 } // namespace | 2732 } // namespace |
2703 } // namespace test | 2733 } // namespace test |
2704 } // namespace net | 2734 } // namespace net |
OLD | NEW |