| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/socket/socks5_client_socket.h" | 5 #include "net/socket/socks5_client_socket.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Create a SOCKS socket, with mock transport socket. | 197 // Create a SOCKS socket, with mock transport socket. |
| 198 MockWrite data_writes[] = {MockWrite()}; | 198 MockWrite data_writes[] = {MockWrite()}; |
| 199 MockRead data_reads[] = {MockRead()}; | 199 MockRead data_reads[] = {MockRead()}; |
| 200 user_sock_.reset(BuildMockSocket(data_reads, data_writes, | 200 user_sock_.reset(BuildMockSocket(data_reads, data_writes, |
| 201 large_host_name, 80)); | 201 large_host_name, 80)); |
| 202 | 202 |
| 203 // Try to connect -- should fail (without having read/written anything to | 203 // Try to connect -- should fail (without having read/written anything to |
| 204 // the transport socket first) because the hostname is too long. | 204 // the transport socket first) because the hostname is too long. |
| 205 TestCompletionCallback callback; | 205 TestCompletionCallback callback; |
| 206 int rv = user_sock_->Connect(&callback, NULL); | 206 int rv = user_sock_->Connect(&callback, NULL); |
| 207 EXPECT_EQ(ERR_INVALID_URL, rv); | 207 EXPECT_EQ(ERR_SOCKS_CONNECTION_FAILED, rv); |
| 208 } | 208 } |
| 209 | 209 |
| 210 TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { | 210 TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { |
| 211 const std::string hostname = "www.google.com"; | 211 const std::string hostname = "www.google.com"; |
| 212 | 212 |
| 213 const char kSOCKS5OkRequest[] = { | 213 const char kSOCKS5OkRequest[] = { |
| 214 0x05, // Version | 214 0x05, // Version |
| 215 0x01, // Command (CONNECT) | 215 0x01, // Command (CONNECT) |
| 216 0x00, // Reserved. | 216 0x00, // Reserved. |
| 217 0x03, // Address type (DOMAINNAME). | 217 0x03, // Address type (DOMAINNAME). |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 rv = callback_.WaitForResult(); | 310 rv = callback_.WaitForResult(); |
| 311 EXPECT_EQ(OK, rv); | 311 EXPECT_EQ(OK, rv); |
| 312 EXPECT_TRUE(user_sock_->IsConnected()); | 312 EXPECT_TRUE(user_sock_->IsConnected()); |
| 313 EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); | 313 EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace | 317 } // namespace |
| 318 | 318 |
| 319 } // namespace net | 319 } // namespace net |
| OLD | NEW |