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

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

Issue 552164: Merge 34903, 34928, 35008, 35549, 36054 to the 249s branch.... (Closed) Base URL: svn://chrome-svn/chrome/branches/249s/src/
Patch Set: Fix some other merge conflicts Created 10 years, 10 months 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
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/proxy/proxy_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ssl_config_service_defaults.h" 10 #include "net/base/ssl_config_service_defaults.h"
(...skipping 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 scoped_ptr<HttpTransaction> trans( 3416 scoped_ptr<HttpTransaction> trans(
3417 new HttpNetworkTransaction(CreateSession(&session_deps))); 3417 new HttpNetworkTransaction(CreateSession(&session_deps)));
3418 3418
3419 HttpRequestInfo request; 3419 HttpRequestInfo request;
3420 request.method = "GET"; 3420 request.method = "GET";
3421 request.url = GURL("http://www.google.com/"); 3421 request.url = GURL("http://www.google.com/");
3422 request.load_flags = 0; 3422 request.load_flags = 0;
3423 3423
3424 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 3424 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
3425 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 3425 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
3426 const char kSOCKS5OkRequest[] = 3426 const char kSOCKS5OkRequest[] = {
3427 { 0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 3427 0x05, // Version
3428 0x01, // Command (CONNECT)
3429 0x00, // Reserved.
3430 0x03, // Address type (DOMAINNAME).
3431 0x0E, // Length of domain (14)
3432 // Domain string:
3433 'w', 'w', 'w', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', 'm',
3434 0x00, 0x50, // 16-bit port (80)
3435 };
3428 const char kSOCKS5OkResponse[] = 3436 const char kSOCKS5OkResponse[] =
3429 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 3437 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
3430 3438
3431 MockWrite data_writes[] = { 3439 MockWrite data_writes[] = {
3432 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)), 3440 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)),
3433 MockWrite(true, kSOCKS5OkRequest, arraysize(kSOCKS5OkRequest)), 3441 MockWrite(true, kSOCKS5OkRequest, arraysize(kSOCKS5OkRequest)),
3434 MockWrite("GET / HTTP/1.1\r\n" 3442 MockWrite("GET / HTTP/1.1\r\n"
3435 "Host: www.google.com\r\n" 3443 "Host: www.google.com\r\n"
3436 "Connection: keep-alive\r\n\r\n") 3444 "Connection: keep-alive\r\n\r\n")
3437 }; 3445 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3472 scoped_ptr<HttpTransaction> trans( 3480 scoped_ptr<HttpTransaction> trans(
3473 new HttpNetworkTransaction(CreateSession(&session_deps))); 3481 new HttpNetworkTransaction(CreateSession(&session_deps)));
3474 3482
3475 HttpRequestInfo request; 3483 HttpRequestInfo request;
3476 request.method = "GET"; 3484 request.method = "GET";
3477 request.url = GURL("https://www.google.com/"); 3485 request.url = GURL("https://www.google.com/");
3478 request.load_flags = 0; 3486 request.load_flags = 0;
3479 3487
3480 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 3488 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
3481 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 3489 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
3482 const unsigned char kSOCKS5OkRequest[] = 3490 const unsigned char kSOCKS5OkRequest[] = {
3483 { 0x05, 0x01, 0x00, 0x01, 127, 0, 0, 1, 0x01, 0xBB }; 3491 0x05, // Version
3492 0x01, // Command (CONNECT)
3493 0x00, // Reserved.
3494 0x03, // Address type (DOMAINNAME).
3495 0x0E, // Length of domain (14)
3496 // Domain string:
3497 'w', 'w', 'w', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', 'm',
3498 0x01, 0xBB, // 16-bit port (443)
3499 };
3500
3484 const char kSOCKS5OkResponse[] = 3501 const char kSOCKS5OkResponse[] =
3485 { 0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0x00, 0x00 }; 3502 { 0x05, 0x00, 0x00, 0x01, 0, 0, 0, 0, 0x00, 0x00 };
3486 3503
3487 MockWrite data_writes[] = { 3504 MockWrite data_writes[] = {
3488 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)), 3505 MockWrite(true, kSOCKS5GreetRequest, arraysize(kSOCKS5GreetRequest)),
3489 MockWrite(true, reinterpret_cast<const char*>(kSOCKS5OkRequest), 3506 MockWrite(true, reinterpret_cast<const char*>(kSOCKS5OkRequest),
3490 arraysize(kSOCKS5OkRequest)), 3507 arraysize(kSOCKS5OkRequest)),
3491 MockWrite("GET / HTTP/1.1\r\n" 3508 MockWrite("GET / HTTP/1.1\r\n"
3492 "Host: www.google.com\r\n" 3509 "Host: www.google.com\r\n"
3493 "Connection: keep-alive\r\n\r\n") 3510 "Connection: keep-alive\r\n\r\n")
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 EXPECT_EQ(ERR_IO_PENDING, trans->Start(&request, &callback, NULL)); 3606 EXPECT_EQ(ERR_IO_PENDING, trans->Start(&request, &callback, NULL));
3590 EXPECT_EQ(tests[i].expected_group_name, 3607 EXPECT_EQ(tests[i].expected_group_name,
3591 conn_pool->last_group_name_received()); 3608 conn_pool->last_group_name_received());
3592 } 3609 }
3593 } 3610 }
3594 3611
3595 TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) { 3612 TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) {
3596 SessionDependencies session_deps( 3613 SessionDependencies session_deps(
3597 CreateFixedProxyService("myproxy:70;foobar:80")); 3614 CreateFixedProxyService("myproxy:70;foobar:80"));
3598 3615
3616 // This simulates failure resolving all hostnames; that means we will fail
3617 // connecting to both proxies (myproxy:70 and foobar:80).
3599 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); 3618 session_deps.host_resolver->rules()->AddSimulatedFailure("*");
3600 3619
3601 scoped_ptr<HttpTransaction> trans( 3620 scoped_ptr<HttpTransaction> trans(
3602 new HttpNetworkTransaction(CreateSession(&session_deps))); 3621 new HttpNetworkTransaction(CreateSession(&session_deps)));
3603 3622
3604 HttpRequestInfo request; 3623 HttpRequestInfo request;
3605 request.method = "GET"; 3624 request.method = "GET";
3606 request.url = GURL("http://www.google.com/"); 3625 request.url = GURL("http://www.google.com/");
3607 3626
3608 TestCompletionCallback callback; 3627 TestCompletionCallback callback;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), 3956 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"),
3938 MockRead(false, OK), 3957 MockRead(false, OK),
3939 }; 3958 };
3940 SimpleGetHelperResult out = SimpleGetHelper(data_reads); 3959 SimpleGetHelperResult out = SimpleGetHelper(data_reads);
3941 EXPECT_EQ(OK, out.rv); 3960 EXPECT_EQ(OK, out.rv);
3942 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); 3961 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line);
3943 EXPECT_EQ("", out.response_data); 3962 EXPECT_EQ("", out.response_data);
3944 } 3963 }
3945 3964
3946 } // namespace net 3965 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/proxy/proxy_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698