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 10062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10073 // connection was attempted with TLSv1. This is transparent to the caller | 10073 // connection was attempted with TLSv1. This is transparent to the caller |
10074 // of the HttpNetworkTransaction. Because this test failure is due to | 10074 // of the HttpNetworkTransaction. Because this test failure is due to |
10075 // requiring a client certificate, this fallback handshake should also | 10075 // requiring a client certificate, this fallback handshake should also |
10076 // fail. | 10076 // fail. |
10077 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 10077 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
10078 ssl_data4.cert_request_info = cert_request.get(); | 10078 ssl_data4.cert_request_info = cert_request.get(); |
10079 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10079 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10080 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); | 10080 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); |
10081 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10081 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10082 | 10082 |
| 10083 // Need one more if TLSv1.2 is enabled. |
| 10084 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 10085 ssl_data5.cert_request_info = cert_request.get(); |
| 10086 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10087 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); |
| 10088 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10089 |
10083 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10090 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10084 scoped_ptr<HttpTransaction> trans( | 10091 scoped_ptr<HttpTransaction> trans( |
10085 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10092 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10086 | 10093 |
10087 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 10094 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
10088 TestCompletionCallback callback; | 10095 TestCompletionCallback callback; |
10089 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10096 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10090 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10097 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10091 | 10098 |
10092 // Complete the SSL handshake, which should abort due to requiring a | 10099 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10186 | 10193 |
10187 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection | 10194 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection |
10188 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. | 10195 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. |
10189 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); | 10196 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); |
10190 ssl_data4.cert_request_info = cert_request.get(); | 10197 ssl_data4.cert_request_info = cert_request.get(); |
10191 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10198 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10192 net::StaticSocketDataProvider data4( | 10199 net::StaticSocketDataProvider data4( |
10193 data2_reads, arraysize(data2_reads), NULL, 0); | 10200 data2_reads, arraysize(data2_reads), NULL, 0); |
10194 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10201 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10195 | 10202 |
| 10203 // Need one more if TLSv1.2 is enabled. |
| 10204 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); |
| 10205 ssl_data5.cert_request_info = cert_request.get(); |
| 10206 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10207 net::StaticSocketDataProvider data5( |
| 10208 data2_reads, arraysize(data2_reads), NULL, 0); |
| 10209 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10210 |
10196 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10211 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10197 scoped_ptr<HttpTransaction> trans( | 10212 scoped_ptr<HttpTransaction> trans( |
10198 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10213 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10199 | 10214 |
10200 // Begin the initial SSL handshake. | 10215 // Begin the initial SSL handshake. |
10201 TestCompletionCallback callback; | 10216 TestCompletionCallback callback; |
10202 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10217 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10203 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10218 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10204 | 10219 |
10205 // Complete the SSL handshake, which should abort due to requiring a | 10220 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11181 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11196 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11182 MessageLoop::current()->RunUntilIdle(); | 11197 MessageLoop::current()->RunUntilIdle(); |
11183 data2->RunFor(3); | 11198 data2->RunFor(3); |
11184 | 11199 |
11185 ASSERT_TRUE(callback2.have_result()); | 11200 ASSERT_TRUE(callback2.have_result()); |
11186 EXPECT_EQ(OK, callback2.WaitForResult()); | 11201 EXPECT_EQ(OK, callback2.WaitForResult()); |
11187 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11202 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11188 } | 11203 } |
11189 | 11204 |
11190 } // namespace net | 11205 } // namespace net |
OLD | NEW |