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 10084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10095 // connection was attempted with TLSv1. This is transparent to the caller | 10095 // connection was attempted with TLSv1. This is transparent to the caller |
10096 // of the HttpNetworkTransaction. Because this test failure is due to | 10096 // of the HttpNetworkTransaction. Because this test failure is due to |
10097 // requiring a client certificate, this fallback handshake should also | 10097 // requiring a client certificate, this fallback handshake should also |
10098 // fail. | 10098 // fail. |
10099 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 10099 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
10100 ssl_data4.cert_request_info = cert_request.get(); | 10100 ssl_data4.cert_request_info = cert_request.get(); |
10101 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10101 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10102 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); | 10102 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); |
10103 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10103 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10104 | 10104 |
| 10105 // Need one more if TLSv1.2 is enabled. |
| 10106 SSLSocketDataProvider ssl_data5(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 10107 ssl_data5.cert_request_info = cert_request.get(); |
| 10108 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10109 net::StaticSocketDataProvider data5(NULL, 0, NULL, 0); |
| 10110 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10111 |
10105 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10112 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10106 scoped_ptr<HttpTransaction> trans( | 10113 scoped_ptr<HttpTransaction> trans( |
10107 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10114 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10108 | 10115 |
10109 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 10116 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
10110 TestCompletionCallback callback; | 10117 TestCompletionCallback callback; |
10111 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10118 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10112 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10119 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10113 | 10120 |
10114 // Complete the SSL handshake, which should abort due to requiring a | 10121 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10208 | 10215 |
10209 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection | 10216 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection |
10210 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. | 10217 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. |
10211 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); | 10218 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); |
10212 ssl_data4.cert_request_info = cert_request.get(); | 10219 ssl_data4.cert_request_info = cert_request.get(); |
10213 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 10220 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
10214 net::StaticSocketDataProvider data4( | 10221 net::StaticSocketDataProvider data4( |
10215 data2_reads, arraysize(data2_reads), NULL, 0); | 10222 data2_reads, arraysize(data2_reads), NULL, 0); |
10216 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 10223 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
10217 | 10224 |
| 10225 // Need one more if TLSv1.2 is enabled. |
| 10226 SSLSocketDataProvider ssl_data5(ASYNC, net::OK); |
| 10227 ssl_data5.cert_request_info = cert_request.get(); |
| 10228 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); |
| 10229 net::StaticSocketDataProvider data5( |
| 10230 data2_reads, arraysize(data2_reads), NULL, 0); |
| 10231 session_deps_.socket_factory->AddSocketDataProvider(&data5); |
| 10232 |
10218 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 10233 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
10219 scoped_ptr<HttpTransaction> trans( | 10234 scoped_ptr<HttpTransaction> trans( |
10220 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); | 10235 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); |
10221 | 10236 |
10222 // Begin the initial SSL handshake. | 10237 // Begin the initial SSL handshake. |
10223 TestCompletionCallback callback; | 10238 TestCompletionCallback callback; |
10224 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 10239 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
10225 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 10240 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
10226 | 10241 |
10227 // Complete the SSL handshake, which should abort due to requiring a | 10242 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11330 EXPECT_EQ("hello!", response_data); | 11345 EXPECT_EQ("hello!", response_data); |
11331 EXPECT_FALSE( | 11346 EXPECT_FALSE( |
11332 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11347 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11333 EXPECT_FALSE( | 11348 EXPECT_FALSE( |
11334 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11349 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11335 | 11350 |
11336 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11351 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
11337 } | 11352 } |
11338 | 11353 |
11339 } // namespace net | 11354 } // namespace net |
OLD | NEW |