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 <cstdint> | 8 #include <cstdint> |
9 #include <list> | 9 #include <list> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 | 1810 |
1811 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1811 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1812 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1812 server_thread_->WaitForCryptoHandshakeConfirmed(); |
1813 | 1813 |
1814 server_thread_->Pause(); | 1814 server_thread_->Pause(); |
1815 QuicSpdySession* const client_session = client_->client()->session(); | 1815 QuicSpdySession* const client_session = client_->client()->session(); |
1816 QuicDispatcher* dispatcher = | 1816 QuicDispatcher* dispatcher = |
1817 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1817 QuicServerPeer::GetDispatcher(server_thread_->server()); |
1818 auto server_session = static_cast<QuicSpdySession*>( | 1818 auto server_session = static_cast<QuicSpdySession*>( |
1819 dispatcher->session_map().begin()->second.get()); | 1819 dispatcher->session_map().begin()->second.get()); |
1820 | |
1821 ExpectFlowControlsSynced(client_session->flow_controller(), | 1820 ExpectFlowControlsSynced(client_session->flow_controller(), |
1822 server_session->flow_controller()); | 1821 server_session->flow_controller()); |
1823 ExpectFlowControlsSynced( | 1822 ExpectFlowControlsSynced( |
1824 QuicSessionPeer::GetCryptoStream(client_session)->flow_controller(), | 1823 QuicSessionPeer::GetCryptoStream(client_session)->flow_controller(), |
1825 QuicSessionPeer::GetCryptoStream(server_session)->flow_controller()); | 1824 QuicSessionPeer::GetCryptoStream(server_session)->flow_controller()); |
1826 ExpectFlowControlsSynced( | 1825 SpdyFramer spdy_framer(HTTP2); |
1827 QuicSpdySessionPeer::GetHeadersStream(client_session)->flow_controller(), | 1826 SpdySettingsIR settings_frame; |
1828 QuicSpdySessionPeer::GetHeadersStream(server_session)->flow_controller()); | 1827 settings_frame.AddSetting(SETTINGS_MAX_HEADER_LIST_SIZE, false, false, |
| 1828 kDefaultMaxUncompressedHeaderSize); |
| 1829 SpdySerializedFrame frame(spdy_framer.SerializeFrame(settings_frame)); |
| 1830 QuicFlowController* client_header_stream_flow_controller = |
| 1831 QuicSpdySessionPeer::GetHeadersStream(client_session)->flow_controller(); |
| 1832 QuicFlowController* server_header_stream_flow_controller = |
| 1833 QuicSpdySessionPeer::GetHeadersStream(server_session)->flow_controller(); |
| 1834 if (FLAGS_quic_send_max_header_list_size) { |
| 1835 // Both client and server are sending this SETTINGS frame, and the send |
| 1836 // window is consumed. But because of timing issue, the server may send or |
| 1837 // not send the frame, and the client may send/ not send / receive / not |
| 1838 // receive the frame. |
| 1839 // TODO(fayang): Rewrite this part because it is hacky. |
| 1840 QuicByteCount win_difference1 = QuicFlowControllerPeer::ReceiveWindowSize( |
| 1841 server_header_stream_flow_controller) - |
| 1842 QuicFlowControllerPeer::SendWindowSize( |
| 1843 client_header_stream_flow_controller); |
| 1844 QuicByteCount win_difference2 = QuicFlowControllerPeer::ReceiveWindowSize( |
| 1845 client_header_stream_flow_controller) - |
| 1846 QuicFlowControllerPeer::SendWindowSize( |
| 1847 server_header_stream_flow_controller); |
| 1848 EXPECT_TRUE(win_difference1 == 0 || win_difference1 == frame.size()); |
| 1849 EXPECT_TRUE(win_difference2 == 0 || win_difference2 == frame.size()); |
| 1850 } else { |
| 1851 ExpectFlowControlsSynced( |
| 1852 QuicSpdySessionPeer::GetHeadersStream(client_session) |
| 1853 ->flow_controller(), |
| 1854 QuicSpdySessionPeer::GetHeadersStream(server_session) |
| 1855 ->flow_controller()); |
| 1856 } |
1829 | 1857 |
1830 if (!client_session->force_hol_blocking()) { | 1858 if (!client_session->force_hol_blocking()) { |
1831 EXPECT_EQ(static_cast<float>(QuicFlowControllerPeer::ReceiveWindowSize( | 1859 if (FLAGS_quic_send_max_header_list_size) { |
1832 client_session->flow_controller())) / | 1860 // Client *may* have received the SETTINGs frame. |
1833 QuicFlowControllerPeer::ReceiveWindowSize( | 1861 // TODO(fayang): Rewrite this part because it is hacky. |
1834 QuicSpdySessionPeer::GetHeadersStream(client_session) | 1862 float ratio1 = |
1835 ->flow_controller()), | 1863 static_cast<float>(QuicFlowControllerPeer::ReceiveWindowSize( |
1836 kSessionToStreamRatio); | 1864 client_session->flow_controller())) / |
| 1865 QuicFlowControllerPeer::ReceiveWindowSize( |
| 1866 QuicSpdySessionPeer::GetHeadersStream(client_session) |
| 1867 ->flow_controller()); |
| 1868 float ratio2 = |
| 1869 static_cast<float>(QuicFlowControllerPeer::ReceiveWindowSize( |
| 1870 client_session->flow_controller())) / |
| 1871 (QuicFlowControllerPeer::ReceiveWindowSize( |
| 1872 QuicSpdySessionPeer::GetHeadersStream(client_session) |
| 1873 ->flow_controller()) + |
| 1874 frame.size()); |
| 1875 EXPECT_TRUE(ratio1 == kSessionToStreamRatio || |
| 1876 ratio2 == kSessionToStreamRatio); |
| 1877 } else { |
| 1878 EXPECT_EQ(static_cast<float>(QuicFlowControllerPeer::ReceiveWindowSize( |
| 1879 client_session->flow_controller())) / |
| 1880 QuicFlowControllerPeer::ReceiveWindowSize( |
| 1881 QuicSpdySessionPeer::GetHeadersStream(client_session) |
| 1882 ->flow_controller()), |
| 1883 kSessionToStreamRatio); |
| 1884 } |
1837 } | 1885 } |
1838 | 1886 |
1839 server_thread_->Resume(); | 1887 server_thread_->Resume(); |
1840 } | 1888 } |
1841 | 1889 |
1842 TEST_P(EndToEndTest, RequestWithNoBodyWillNeverSendStreamFrameWithFIN) { | 1890 TEST_P(EndToEndTest, RequestWithNoBodyWillNeverSendStreamFrameWithFIN) { |
1843 // A stream created on receipt of a simple request with no body will never get | 1891 // A stream created on receipt of a simple request with no body will never get |
1844 // a stream frame with a FIN. Verify that we don't keep track of the stream in | 1892 // a stream frame with a FIN. Verify that we don't keep track of the stream in |
1845 // the locally closed streams map: it will never be removed if so. | 1893 // the locally closed streams map: it will never be removed if so. |
1846 ASSERT_TRUE(Initialize()); | 1894 ASSERT_TRUE(Initialize()); |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 client_->WaitForResponse(); | 3038 client_->WaitForResponse(); |
2991 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 3039 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2992 QuicConnectionStats client_stats = | 3040 QuicConnectionStats client_stats = |
2993 client_->client()->session()->connection()->GetStats(); | 3041 client_->client()->session()->connection()->GetStats(); |
2994 EXPECT_EQ(0u, client_stats.packets_lost); | 3042 EXPECT_EQ(0u, client_stats.packets_lost); |
2995 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 3043 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2996 } | 3044 } |
2997 } // namespace | 3045 } // namespace |
2998 } // namespace test | 3046 } // namespace test |
2999 } // namespace net | 3047 } // namespace net |
OLD | NEW |