OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 10044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10055 // connection was attempted with TLSv1. This is transparent to the caller | 10055 // connection was attempted with TLSv1. This is transparent to the caller |
10056 // of the HttpNetworkTransaction. Because this test failure is due to | 10056 // of the HttpNetworkTransaction. Because this test failure is due to |
10057 // requiring a client certificate, this fallback handshake should also | 10057 // requiring a client certificate, this fallback handshake should also |
10058 // fail. | 10058 // fail. |
10059 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 10059 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
10060 ssl_data4.cert_request_info = cert_request.get(); | 10060 ssl_data4.cert_request_info = cert_request.get(); |
10061 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10061 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10062 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); | 10062 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); |
10063 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10063 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10064 | 10064 |
| 10065 // Need one more if TLSv1.2 is enabled. |
| 10066 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 10067 ssl_data5.cert_request_info = cert_request.get(); |
| 10068 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10069 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); |
| 10070 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10071 |
10065 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10072 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10066 scoped_ptr<HttpTransaction> trans( | 10073 scoped_ptr<HttpTransaction> trans( |
10067 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10074 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10068 | 10075 |
10069 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 10076 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
10070 TestCompletionCallback callback; | 10077 TestCompletionCallback callback; |
10071 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10078 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10072 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10079 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10073 | 10080 |
10074 // Complete the SSL handshake, which should abort due to requiring a | 10081 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10168 | 10175 |
10169 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection | 10176 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection |
10170 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. | 10177 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. |
10171 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); | 10178 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); |
10172 ssl_data4.cert_request_info = cert_request.get(); | 10179 ssl_data4.cert_request_info = cert_request.get(); |
10173 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10180 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10174 net::StaticSocketDataProvider data4( | 10181 net::StaticSocketDataProvider data4( |
10175 data2_reads, arraysize(data2_reads), NULL, 0); | 10182 data2_reads, arraysize(data2_reads), NULL, 0); |
10176 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10183 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10177 | 10184 |
| 10185 // Need one more if TLSv1.2 is enabled. |
| 10186 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); |
| 10187 ssl_data5.cert_request_info = cert_request.get(); |
| 10188 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10189 net::StaticSocketDataProvider data5( |
| 10190 data2_reads, arraysize(data2_reads), NULL, 0); |
| 10191 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10192 |
10178 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10193 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10179 scoped_ptr<HttpTransaction> trans( | 10194 scoped_ptr<HttpTransaction> trans( |
10180 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10195 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10181 | 10196 |
10182 // Begin the initial SSL handshake. | 10197 // Begin the initial SSL handshake. |
10183 TestCompletionCallback callback; | 10198 TestCompletionCallback callback; |
10184 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10199 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10185 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10200 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10186 | 10201 |
10187 // Complete the SSL handshake, which should abort due to requiring a | 10202 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11126 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11141 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11127 MessageLoop::current()->RunUntilIdle(); | 11142 MessageLoop::current()->RunUntilIdle(); |
11128 data2->RunFor(3); | 11143 data2->RunFor(3); |
11129 | 11144 |
11130 ASSERT_TRUE(callback2.have_result()); | 11145 ASSERT_TRUE(callback2.have_result()); |
11131 EXPECT_EQ(OK, callback2.WaitForResult()); | 11146 EXPECT_EQ(OK, callback2.WaitForResult()); |
11132 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11147 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11133 } | 11148 } |
11134 | 11149 |
11135 } // namespace net | 11150 } // namespace net |
OLD | NEW |