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

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

Issue 3056040: Revert 54405 - Fix late binding induced mismatch of Socket and AuthController... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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/http/http_proxy_client_socket.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 1336
1337 rv = callback2.WaitForResult(); 1337 rv = callback2.WaitForResult();
1338 EXPECT_EQ(OK, rv); 1338 EXPECT_EQ(OK, rv);
1339 1339
1340 response = trans->GetResponseInfo(); 1340 response = trans->GetResponseInfo();
1341 ASSERT_FALSE(response == NULL); 1341 ASSERT_FALSE(response == NULL);
1342 EXPECT_TRUE(response->auth_challenge.get() == NULL); 1342 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1343 EXPECT_EQ(100, response->headers->GetContentLength()); 1343 EXPECT_EQ(100, response->headers->GetContentLength());
1344 } 1344 }
1345 1345
1346 // Test the request-challenge-retry sequence for basic auth, over a connection
1347 // that requires a restart when setting up an SSL tunnel.
1348 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAlive) {
1349 // Configure against proxy server "myproxy:70".
1350 SessionDependencies session_deps(CreateFixedProxyService("myproxy:70"));
1351 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
1352 session_deps.net_log = log.bound().net_log();
1353 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
1354
1355 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
1356
1357 HttpRequestInfo request;
1358 request.method = "GET";
1359 request.url = GURL("https://www.google.com/");
1360 // when the no authentication data flag is set.
1361 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA;
1362
1363 // Since we have proxy, should try to establish tunnel.
1364 MockWrite data_writes1[] = {
1365 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n"
1366 "Host: www.google.com\r\n"
1367 "Proxy-Connection: keep-alive\r\n\r\n"),
1368
1369 // After calling trans->RestartWithAuth(), this is the request we should
1370 // be issuing -- the final header line contains the credentials.
1371 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n"
1372 "Host: www.google.com\r\n"
1373 "Proxy-Connection: keep-alive\r\n"
1374 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
1375
1376 MockWrite("GET / HTTP/1.1\r\n"
1377 "Host: www.google.com\r\n"
1378 "Connection: keep-alive\r\n\r\n"),
1379 };
1380
1381 // The proxy responds to the connect with a 407, using a persistent
1382 // connection.
1383 MockRead data_reads1[] = {
1384 // No credentials.
1385 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"),
1386 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
1387 MockRead("Proxy-Connection: close\r\n\r\n"),
1388
1389 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"),
1390
1391 MockRead("HTTP/1.1 200 OK\r\n"),
1392 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
1393 MockRead("Content-Length: 100\r\n\r\n"),
1394 MockRead(false, OK),
1395 };
1396
1397 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1),
1398 data_writes1, arraysize(data_writes1));
1399 session_deps.socket_factory.AddSocketDataProvider(&data1);
1400 SSLSocketDataProvider ssl(true, OK);
1401 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
1402
1403 TestCompletionCallback callback1;
1404
1405 int rv = trans->Start(&request, &callback1, log.bound());
1406 EXPECT_EQ(ERR_IO_PENDING, rv);
1407
1408 rv = callback1.WaitForResult();
1409 EXPECT_EQ(OK, rv);
1410 size_t pos = ExpectLogContainsSomewhere(
1411 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
1412 NetLog::PHASE_NONE);
1413 ExpectLogContainsSomewhere(
1414 log.entries(), pos,
1415 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
1416 NetLog::PHASE_NONE);
1417
1418 const HttpResponseInfo* response = trans->GetResponseInfo();
1419 ASSERT_FALSE(response == NULL);
1420
1421 EXPECT_EQ(407, response->headers->response_code());
1422 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion());
1423
1424 // The password prompt info should have been set in response->auth_challenge.
1425 ASSERT_FALSE(response->auth_challenge.get() == NULL);
1426
1427 EXPECT_EQ(L"myproxy:70", response->auth_challenge->host_and_port);
1428 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm);
1429 EXPECT_EQ(L"basic", response->auth_challenge->scheme);
1430
1431 TestCompletionCallback callback2;
1432
1433 rv = trans->RestartWithAuth(kFoo, kBar, &callback2);
1434 EXPECT_EQ(ERR_IO_PENDING, rv);
1435
1436 rv = callback2.WaitForResult();
1437 EXPECT_EQ(OK, rv);
1438
1439 response = trans->GetResponseInfo();
1440 ASSERT_FALSE(response == NULL);
1441
1442 EXPECT_TRUE(response->headers->IsKeepAlive());
1443 EXPECT_EQ(200, response->headers->response_code());
1444 EXPECT_EQ(100, response->headers->GetContentLength());
1445 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion());
1446
1447 // The password prompt info should not be set.
1448 EXPECT_TRUE(response->auth_challenge.get() == NULL);
1449 }
1450
1451 // Test the request-challenge-retry sequence for basic auth, over a keep-alive 1346 // Test the request-challenge-retry sequence for basic auth, over a keep-alive
1452 // proxy connection, when setting up an SSL tunnel. 1347 // proxy connection, when setting up an SSL tunnel.
1453 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) { 1348 TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) {
1454 // Configure against proxy server "myproxy:70". 1349 // Configure against proxy server "myproxy:70".
1455 SessionDependencies session_deps(CreateFixedProxyService("myproxy:70")); 1350 SessionDependencies session_deps(CreateFixedProxyService("myproxy:70"));
1456 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); 1351 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
1457 session_deps.net_log = log.bound().net_log(); 1352 session_deps.net_log = log.bound().net_log();
1458 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); 1353 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
1459 1354
1460 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 1355 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
(...skipping 4906 matching lines...) Expand 10 before | Expand all | Expand 10 after
6367 6262
6368 int rv = trans->Start(&request, &callback, BoundNetLog()); 6263 int rv = trans->Start(&request, &callback, BoundNetLog());
6369 EXPECT_EQ(ERR_IO_PENDING, rv); 6264 EXPECT_EQ(ERR_IO_PENDING, rv);
6370 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); 6265 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult());
6371 6266
6372 HttpNetworkTransaction::SetNextProtos(""); 6267 HttpNetworkTransaction::SetNextProtos("");
6373 HttpNetworkTransaction::SetUseAlternateProtocols(false); 6268 HttpNetworkTransaction::SetUseAlternateProtocols(false);
6374 } 6269 }
6375 6270
6376 } // namespace net 6271 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_proxy_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698