Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 507033: When talking to a SOCKS v5 proxy, default to sending addresses as raw domains... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc's comments Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <math.h> // ceil 5 #include <math.h> // ceil
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/mock_host_resolver.h" 9 #include "net/base/mock_host_resolver.h"
10 #include "net/base/request_priority.h" 10 #include "net/base/request_priority.h"
(...skipping 3348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 scoped_ptr<HttpTransaction> trans( 3359 scoped_ptr<HttpTransaction> trans(
3360 new HttpNetworkTransaction(CreateSession(&session_deps))); 3360 new HttpNetworkTransaction(CreateSession(&session_deps)));
3361 3361
3362 HttpRequestInfo request; 3362 HttpRequestInfo request;
3363 request.method = "GET"; 3363 request.method = "GET";
3364 request.url = GURL("http://www.google.com/"); 3364 request.url = GURL("http://www.google.com/");
3365 request.load_flags = 0; 3365 request.load_flags = 0;
3366 3366
3367 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 3367 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
3368 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 3368 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
3369 const char kSOCKS5OkRequest[] = 3369 const char kSOCKS5OkRequest[] = {
3370 { 0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 3370 0x05, // Version
3371 0x01, // Command (CONNECT)
3372 0x00, // Reserved.
3373 0x03, // Address type (DOMAINNAME).
3374 0x0E, // Length of domain (14)
3375 // Domain string:
3376 'w', 'w', 'w', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', 'm',
3377 0x00, 0x50, // 16-bit port (80)
3378 };
3371 const char kSOCKS5OkResponse[] = 3379 const char kSOCKS5OkResponse[] =
3372 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 3380 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
3373 3381
3374 MockWrite data_writes[] = { 3382 MockWrite data_writes[] = {
3375 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)), 3383 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)),
3376 MockWrite(true, kSOCKS5OkRequest, arraysize(kSOCKS5OkRequest)), 3384 MockWrite(true, kSOCKS5OkRequest, arraysize(kSOCKS5OkRequest)),
3377 MockWrite("GET / HTTP/1.1\r\n" 3385 MockWrite("GET / HTTP/1.1\r\n"
3378 "Host: www.google.com\r\n" 3386 "Host: www.google.com\r\n"
3379 "Connection: keep-alive\r\n\r\n") 3387 "Connection: keep-alive\r\n\r\n")
3380 }; 3388 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3415 scoped_ptr<HttpTransaction> trans( 3423 scoped_ptr<HttpTransaction> trans(
3416 new HttpNetworkTransaction(CreateSession(&session_deps))); 3424 new HttpNetworkTransaction(CreateSession(&session_deps)));
3417 3425
3418 HttpRequestInfo request; 3426 HttpRequestInfo request;
3419 request.method = "GET"; 3427 request.method = "GET";
3420 request.url = GURL("https://www.google.com/"); 3428 request.url = GURL("https://www.google.com/");
3421 request.load_flags = 0; 3429 request.load_flags = 0;
3422 3430
3423 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 3431 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
3424 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 3432 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
3425 const unsigned char kSOCKS5OkRequest[] = 3433 const unsigned char kSOCKS5OkRequest[] = {
3426 { 0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0x01, 0xBB }; 3434 0x05, // Version
3435 0x01, // Command (CONNECT)
3436 0x00, // Reserved.
3437 0x03, // Address type (DOMAINNAME).
3438 0x0E, // Length of domain (14)
3439 // Domain string:
3440 'w', 'w', 'w', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', 'm',
3441 0x01, 0xBB, // 16-bit port (443)
3442 };
3443
3427 const char kSOCKS5OkResponse[] = 3444 const char kSOCKS5OkResponse[] =
3428 { 0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0x00, 0x00 }; 3445 { 0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0x00, 0x00 };
3429 3446
3430 MockWrite data_writes[] = { 3447 MockWrite data_writes[] = {
3431 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)), 3448 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)),
3432 MockWrite(true, reinterpret_cast<const char*>(kSOCKS5OkRequest), 3449 MockWrite(true, reinterpret_cast<const char*>(kSOCKS5OkRequest),
3433 arraysize(kSOCKS5OkRequest)), 3450 arraysize(kSOCKS5OkRequest)),
3434 MockWrite("GET / HTTP/1.1\r\n" 3451 MockWrite("GET / HTTP/1.1\r\n"
3435 "Host: www.google.com\r\n" 3452 "Host: www.google.com\r\n"
3436 "Connection: keep-alive\r\n\r\n") 3453 "Connection: keep-alive\r\n\r\n")
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3880 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), 3897 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"),
3881 MockRead(false, OK), 3898 MockRead(false, OK),
3882 }; 3899 };
3883 SimpleGetHelperResult out = SimpleGetHelper(data_reads); 3900 SimpleGetHelperResult out = SimpleGetHelper(data_reads);
3884 EXPECT_EQ(OK, out.rv); 3901 EXPECT_EQ(OK, out.rv);
3885 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); 3902 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
3886 EXPECT_EQ("", out.response_data); 3903 EXPECT_EQ("", out.response_data);
3887 } 3904 }
3888 3905
3889 } // namespace net 3906 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698