| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/websockets/websocket_stream.h" | 5 #include "net/websockets/websocket_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 EXPECT_FALSE(stream_); | 981 EXPECT_FALSE(stream_); |
| 982 EXPECT_TRUE(request_info_); | 982 EXPECT_TRUE(request_info_); |
| 983 EXPECT_FALSE(response_info_); | 983 EXPECT_FALSE(response_info_); |
| 984 } | 984 } |
| 985 | 985 |
| 986 // Over-size response headers (> 256KB) should not cause a crash. This is a | 986 // Over-size response headers (> 256KB) should not cause a crash. This is a |
| 987 // regression test for crbug.com/339456. It is based on the layout test | 987 // regression test for crbug.com/339456. It is based on the layout test |
| 988 // "cookie-flood.html". | 988 // "cookie-flood.html". |
| 989 TEST_F(WebSocketStreamCreateTest, VeryLargeResponseHeaders) { | 989 TEST_F(WebSocketStreamCreateTest, VeryLargeResponseHeaders) { |
| 990 std::string set_cookie_headers; | 990 std::string set_cookie_headers; |
| 991 set_cookie_headers.reserve(45 * 10000); | 991 set_cookie_headers.reserve(24 * 20000); |
| 992 for (int i = 0; i < 10000; ++i) { | 992 for (int i = 0; i < 20000; ++i) { |
| 993 set_cookie_headers += | 993 set_cookie_headers += base::StringPrintf("Set-Cookie: ws-%d=1\r\n", i); |
| 994 base::StringPrintf("Set-Cookie: WK-websocket-test-flood-%d=1\r\n", i); | |
| 995 } | 994 } |
| 995 ASSERT_GT(set_cookie_headers.size(), 256U * 1024U); |
| 996 CreateAndConnectStandard("ws://localhost/", "localhost", "/", | 996 CreateAndConnectStandard("ws://localhost/", "localhost", "/", |
| 997 NoSubProtocols(), LocalhostOrigin(), "", "", | 997 NoSubProtocols(), LocalhostOrigin(), "", "", |
| 998 set_cookie_headers); | 998 set_cookie_headers); |
| 999 WaitUntilConnectDone(); | 999 WaitUntilConnectDone(); |
| 1000 EXPECT_TRUE(has_failed()); | 1000 EXPECT_TRUE(has_failed()); |
| 1001 EXPECT_FALSE(response_info_); | 1001 EXPECT_FALSE(response_info_); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 // If the remote host closes the connection without sending headers, we should | 1004 // If the remote host closes the connection without sending headers, we should |
| 1005 // log the console message "Connection closed before receiving a handshake | 1005 // log the console message "Connection closed before receiving a handshake |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 LocalhostOrigin(), "", | 1234 LocalhostOrigin(), "", |
| 1235 std::move(socket_data)); | 1235 std::move(socket_data)); |
| 1236 WaitUntilConnectDone(); | 1236 WaitUntilConnectDone(); |
| 1237 EXPECT_TRUE(has_failed()); | 1237 EXPECT_TRUE(has_failed()); |
| 1238 EXPECT_EQ("Establishing a tunnel via proxy server failed.", | 1238 EXPECT_EQ("Establishing a tunnel via proxy server failed.", |
| 1239 failure_message()); | 1239 failure_message()); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 } // namespace | 1242 } // namespace |
| 1243 } // namespace net | 1243 } // namespace net |
| OLD | NEW |