| 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 #include <limits> | 10 #include <limits> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "net/socket/client_socket_pool_manager.h" | 68 #include "net/socket/client_socket_pool_manager.h" |
| 69 #include "net/socket/connection_attempts.h" | 69 #include "net/socket/connection_attempts.h" |
| 70 #include "net/socket/mock_client_socket_pool_manager.h" | 70 #include "net/socket/mock_client_socket_pool_manager.h" |
| 71 #include "net/socket/next_proto.h" | 71 #include "net/socket/next_proto.h" |
| 72 #include "net/socket/socket_test_util.h" | 72 #include "net/socket/socket_test_util.h" |
| 73 #include "net/socket/ssl_client_socket.h" | 73 #include "net/socket/ssl_client_socket.h" |
| 74 #include "net/spdy/spdy_framer.h" | 74 #include "net/spdy/spdy_framer.h" |
| 75 #include "net/spdy/spdy_session.h" | 75 #include "net/spdy/spdy_session.h" |
| 76 #include "net/spdy/spdy_session_pool.h" | 76 #include "net/spdy/spdy_session_pool.h" |
| 77 #include "net/spdy/spdy_test_util_common.h" | 77 #include "net/spdy/spdy_test_util_common.h" |
| 78 #include "net/ssl/default_channel_id_store.h" |
| 78 #include "net/ssl/ssl_cert_request_info.h" | 79 #include "net/ssl/ssl_cert_request_info.h" |
| 79 #include "net/ssl/ssl_config_service.h" | 80 #include "net/ssl/ssl_config_service.h" |
| 80 #include "net/ssl/ssl_config_service_defaults.h" | 81 #include "net/ssl/ssl_config_service_defaults.h" |
| 81 #include "net/ssl/ssl_info.h" | 82 #include "net/ssl/ssl_info.h" |
| 82 #include "net/ssl/ssl_private_key.h" | 83 #include "net/ssl/ssl_private_key.h" |
| 83 #include "net/test/cert_test_util.h" | 84 #include "net/test/cert_test_util.h" |
| 84 #include "net/websockets/websocket_handshake_stream_base.h" | 85 #include "net/websockets/websocket_handshake_stream_base.h" |
| 85 #include "testing/gmock/include/gmock/gmock.h" | 86 #include "testing/gmock/include/gmock/gmock.h" |
| 86 #include "testing/gtest/include/gtest/gtest.h" | 87 #include "testing/gtest/include/gtest/gtest.h" |
| 87 #include "testing/platform_test.h" | 88 #include "testing/platform_test.h" |
| (...skipping 14318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14406 } | 14407 } |
| 14407 | 14408 |
| 14408 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); } | 14409 void GetSSLInfo(SSLInfo* ssl_info) override { ADD_FAILURE(); } |
| 14409 | 14410 |
| 14410 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { | 14411 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { |
| 14411 ADD_FAILURE(); | 14412 ADD_FAILURE(); |
| 14412 } | 14413 } |
| 14413 | 14414 |
| 14414 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } | 14415 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } |
| 14415 | 14416 |
| 14417 Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 14418 std::vector<uint8_t>* out) override { |
| 14419 ADD_FAILURE(); |
| 14420 return ERR_NOT_IMPLEMENTED; |
| 14421 } |
| 14422 |
| 14416 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } | 14423 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } |
| 14417 | 14424 |
| 14418 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } | 14425 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } |
| 14419 | 14426 |
| 14420 void SetPriority(RequestPriority priority) override { priority_ = priority; } | 14427 void SetPriority(RequestPriority priority) override { priority_ = priority; } |
| 14421 | 14428 |
| 14422 UploadProgress GetUploadProgress() const override { return UploadProgress(); } | 14429 UploadProgress GetUploadProgress() const override { return UploadProgress(); } |
| 14423 | 14430 |
| 14424 HttpStream* RenewStreamForAuth() override { return NULL; } | 14431 HttpStream* RenewStreamForAuth() override { return NULL; } |
| 14425 | 14432 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14637 } | 14644 } |
| 14638 | 14645 |
| 14639 void GetSSLInfo(SSLInfo* ssl_info) override {} | 14646 void GetSSLInfo(SSLInfo* ssl_info) override {} |
| 14640 | 14647 |
| 14641 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { | 14648 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override { |
| 14642 NOTREACHED(); | 14649 NOTREACHED(); |
| 14643 } | 14650 } |
| 14644 | 14651 |
| 14645 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } | 14652 bool GetRemoteEndpoint(IPEndPoint* endpoint) override { return false; } |
| 14646 | 14653 |
| 14654 Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 14655 std::vector<uint8_t>* out) override { |
| 14656 ADD_FAILURE(); |
| 14657 return ERR_NOT_IMPLEMENTED; |
| 14658 } |
| 14659 |
| 14647 void Drain(HttpNetworkSession* session) override { NOTREACHED(); } | 14660 void Drain(HttpNetworkSession* session) override { NOTREACHED(); } |
| 14648 | 14661 |
| 14649 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } | 14662 void PopulateNetErrorDetails(NetErrorDetails* details) override { return; } |
| 14650 | 14663 |
| 14651 void SetPriority(RequestPriority priority) override { NOTREACHED(); } | 14664 void SetPriority(RequestPriority priority) override { NOTREACHED(); } |
| 14652 | 14665 |
| 14653 UploadProgress GetUploadProgress() const override { | 14666 UploadProgress GetUploadProgress() const override { |
| 14654 NOTREACHED(); | 14667 NOTREACHED(); |
| 14655 return UploadProgress(); | 14668 return UploadProgress(); |
| 14656 } | 14669 } |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15795 session_deps_.enable_npn = false; | 15808 session_deps_.enable_npn = false; |
| 15796 | 15809 |
| 15797 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 15810 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 15798 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 15811 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 15799 | 15812 |
| 15800 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, | 15813 EXPECT_THAT(trans.server_ssl_config_.alpn_protos, |
| 15801 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); | 15814 testing::ElementsAre(kProtoHTTP2, kProtoSPDY31, kProtoHTTP11)); |
| 15802 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); | 15815 EXPECT_TRUE(trans.server_ssl_config_.npn_protos.empty()); |
| 15803 } | 15816 } |
| 15804 | 15817 |
| 15818 #if !defined(OS_IOS) |
| 15819 TEST_P(HttpNetworkTransactionTest, TokenBindingSpdy) { |
| 15820 const std::string https_url = "https://www.example.com"; |
| 15821 HttpRequestInfo request; |
| 15822 request.url = GURL(https_url); |
| 15823 request.method = "GET"; |
| 15824 |
| 15825 SSLSocketDataProvider ssl(ASYNC, OK); |
| 15826 ssl.token_binding_negotiated = true; |
| 15827 ssl.token_binding_key_param = TB_PARAM_ECDSAP256; |
| 15828 ssl.SetNextProto(GetProtocol()); |
| 15829 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 15830 |
| 15831 scoped_ptr<SpdyFrame> resp( |
| 15832 spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); |
| 15833 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 15834 MockRead reads[] = {CreateMockRead(*resp), CreateMockRead(*body), |
| 15835 MockRead(ASYNC, ERR_IO_PENDING)}; |
| 15836 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); |
| 15837 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 15838 session_deps_.channel_id_service.reset(new ChannelIDService( |
| 15839 new DefaultChannelIDStore(nullptr), base::ThreadTaskRunnerHandle::Get())); |
| 15840 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 15841 |
| 15842 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 15843 TestCompletionCallback callback; |
| 15844 EXPECT_EQ(ERR_IO_PENDING, |
| 15845 trans.Start(&request, callback.callback(), BoundNetLog())); |
| 15846 base::MessageLoop::current()->RunUntilIdle(); |
| 15847 |
| 15848 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15849 HttpRequestHeaders headers; |
| 15850 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15851 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15852 } |
| 15853 #endif // !defined(OS_IOS) |
| 15854 |
| 15805 } // namespace net | 15855 } // namespace net |
| OLD | NEW |