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/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 <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 10610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10621 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { | 10621 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { |
10622 // Do multi-round authentication and make sure it works correctly. | 10622 // Do multi-round authentication and make sure it works correctly. |
10623 HttpAuthHandlerMock::Factory* auth_factory( | 10623 HttpAuthHandlerMock::Factory* auth_factory( |
10624 new HttpAuthHandlerMock::Factory()); | 10624 new HttpAuthHandlerMock::Factory()); |
10625 session_deps_.http_auth_handler_factory.reset(auth_factory); | 10625 session_deps_.http_auth_handler_factory.reset(auth_factory); |
10626 session_deps_.proxy_service = ProxyService::CreateDirect(); | 10626 session_deps_.proxy_service = ProxyService::CreateDirect(); |
10627 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); | 10627 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); |
10628 session_deps_.host_resolver->set_synchronous_mode(true); | 10628 session_deps_.host_resolver->set_synchronous_mode(true); |
10629 | 10629 |
10630 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 10630 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
10631 auth_handler->set_connection_based(true); | 10631 auth_handler->set_expect_multiple_challenges(true); |
10632 std::string auth_challenge = "Mock realm=server"; | 10632 std::string auth_challenge = "Mock realm=server"; |
10633 GURL origin("http://www.example.com"); | 10633 GURL origin("http://www.example.com"); |
10634 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), | 10634 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), |
10635 auth_challenge.end()); | 10635 auth_challenge.end()); |
10636 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, | 10636 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, |
10637 origin, BoundNetLog()); | 10637 origin, BoundNetLog()); |
10638 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); | 10638 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); |
10639 | 10639 |
10640 int rv = OK; | 10640 int rv = OK; |
10641 const HttpResponseInfo* response = NULL; | 10641 const HttpResponseInfo* response = NULL; |
(...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14601 MockRead("HTTP/1.1 101 Switching Protocols\r\n"), | 14601 MockRead("HTTP/1.1 101 Switching Protocols\r\n"), |
14602 MockRead("Upgrade: websocket\r\n"), | 14602 MockRead("Upgrade: websocket\r\n"), |
14603 MockRead("Connection: Upgrade\r\n"), | 14603 MockRead("Connection: Upgrade\r\n"), |
14604 MockRead("Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n"), | 14604 MockRead("Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n"), |
14605 }; | 14605 }; |
14606 | 14606 |
14607 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 14607 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
14608 arraysize(data_writes)); | 14608 arraysize(data_writes)); |
14609 session_deps_.socket_factory->AddSocketDataProvider(&data); | 14609 session_deps_.socket_factory->AddSocketDataProvider(&data); |
14610 | 14610 |
14611 session->http_auth_cache()->Add( | 14611 session->http_auth_cache()->Add(GURL("http://myproxy:70/"), "MyRealm1", |
14612 GURL("http://myproxy:70/"), "MyRealm1", HttpAuth::AUTH_SCHEME_BASIC, | 14612 "basic", "Basic realm=MyRealm1", |
14613 "Basic realm=MyRealm1", AuthCredentials(kFoo, kBar), "/"); | 14613 AuthCredentials(kFoo, kBar), "/"); |
14614 | 14614 |
14615 scoped_ptr<HttpTransaction> trans( | 14615 scoped_ptr<HttpTransaction> trans( |
14616 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 14616 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
14617 FakeWebSocketStreamCreateHelper websocket_stream_create_helper; | 14617 FakeWebSocketStreamCreateHelper websocket_stream_create_helper; |
14618 trans->SetWebSocketHandshakeStreamCreateHelper( | 14618 trans->SetWebSocketHandshakeStreamCreateHelper( |
14619 &websocket_stream_create_helper); | 14619 &websocket_stream_create_helper); |
14620 | 14620 |
14621 TestCompletionCallback callback; | 14621 TestCompletionCallback callback; |
14622 | 14622 |
14623 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 14623 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14771 std::string response_data; | 14771 std::string response_data; |
14772 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 14772 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
14773 | 14773 |
14774 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), | 14774 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), |
14775 trans->GetTotalSentBytes()); | 14775 trans->GetTotalSentBytes()); |
14776 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), | 14776 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), |
14777 trans->GetTotalReceivedBytes()); | 14777 trans->GetTotalReceivedBytes()); |
14778 } | 14778 } |
14779 | 14779 |
14780 } // namespace net | 14780 } // namespace net |
OLD | NEW |