OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "net/cert/mock_cert_verifier.h" | 16 #include "net/cert/mock_cert_verifier.h" |
17 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
18 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
19 #include "net/http/http_network_transaction.h" | 19 #include "net/http/http_network_transaction.h" |
| 20 #include "net/http/http_request_headers.h" |
| 21 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_server_properties_impl.h" | 22 #include "net/http/http_server_properties_impl.h" |
21 #include "net/socket/socket_test_util.h" | 23 #include "net/socket/socket_test_util.h" |
22 #include "net/socket/ssl_client_socket.h" | 24 #include "net/socket/ssl_client_socket.h" |
23 #include "net/socket/transport_client_socket_pool.h" | 25 #include "net/socket/transport_client_socket_pool.h" |
24 #include "net/spdy/buffered_spdy_framer.h" | 26 #include "net/spdy/buffered_spdy_framer.h" |
25 #include "net/spdy/spdy_framer.h" | 27 #include "net/spdy/spdy_framer.h" |
26 #include "net/spdy/spdy_http_utils.h" | 28 #include "net/spdy/spdy_http_utils.h" |
27 #include "net/spdy/spdy_session.h" | 29 #include "net/spdy/spdy_session.h" |
28 #include "net/spdy/spdy_session_pool.h" | 30 #include "net/spdy/spdy_session_pool.h" |
29 #include "net/spdy/spdy_stream.h" | 31 #include "net/spdy/spdy_stream.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 params.enable_user_alternate_protocol_ports = | 436 params.enable_user_alternate_protocol_ports = |
435 session_deps->enable_user_alternate_protocol_ports; | 437 session_deps->enable_user_alternate_protocol_ports; |
436 params.enable_npn = session_deps->enable_npn; | 438 params.enable_npn = session_deps->enable_npn; |
437 params.spdy_default_protocol = session_deps->protocol; | 439 params.spdy_default_protocol = session_deps->protocol; |
438 params.spdy_session_max_recv_window_size = | 440 params.spdy_session_max_recv_window_size = |
439 session_deps->session_max_recv_window_size; | 441 session_deps->session_max_recv_window_size; |
440 params.spdy_stream_max_recv_window_size = | 442 params.spdy_stream_max_recv_window_size = |
441 session_deps->stream_max_recv_window_size; | 443 session_deps->stream_max_recv_window_size; |
442 params.time_func = session_deps->time_func; | 444 params.time_func = session_deps->time_func; |
443 params.next_protos = session_deps->next_protos; | 445 params.next_protos = session_deps->next_protos; |
444 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; | 446 params.proxy_delegate = session_deps->proxy_delegate.get(); |
445 params.parse_alternative_services = session_deps->parse_alternative_services; | 447 params.parse_alternative_services = session_deps->parse_alternative_services; |
446 params.enable_alternative_service_with_different_host = | 448 params.enable_alternative_service_with_different_host = |
447 session_deps->enable_alternative_service_with_different_host; | 449 session_deps->enable_alternative_service_with_different_host; |
448 params.net_log = session_deps->net_log; | 450 params.net_log = session_deps->net_log; |
449 return params; | 451 return params; |
450 } | 452 } |
451 | 453 |
452 SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol) | 454 SpdyURLRequestContext::SpdyURLRequestContext(NextProto protocol) |
453 : storage_(this) { | 455 : storage_(this) { |
454 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | 456 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 (*block)[GetVersionKey()] = "HTTP/1.1"; | 1346 (*block)[GetVersionKey()] = "HTTP/1.1"; |
1345 } | 1347 } |
1346 } | 1348 } |
1347 | 1349 |
1348 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1350 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1349 SpdySynStreamIR* ir) const { | 1351 SpdySynStreamIR* ir) const { |
1350 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1352 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1351 priority, spdy_version())); | 1353 priority, spdy_version())); |
1352 } | 1354 } |
1353 | 1355 |
| 1356 TestProxyDelegate::TestProxyDelegate() |
| 1357 : on_before_tunnel_request_called_(false), |
| 1358 on_tunnel_request_completed_called_(false), |
| 1359 on_tunnel_headers_received_called_(false) {} |
| 1360 |
| 1361 TestProxyDelegate::~TestProxyDelegate() {} |
| 1362 |
| 1363 void TestProxyDelegate::VerifyOnTunnelRequestCompleted( |
| 1364 const std::string& endpoint, |
| 1365 const std::string& proxy_server) const { |
| 1366 EXPECT_TRUE(on_tunnel_request_completed_called_); |
| 1367 EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals( |
| 1368 on_tunnel_request_completed_endpoint_)); |
| 1369 EXPECT_TRUE(HostPortPair::FromString(proxy_server) |
| 1370 .Equals(on_tunnel_request_completed_proxy_server_)); |
| 1371 } |
| 1372 |
| 1373 void TestProxyDelegate::VerifyOnTunnelHeadersReceived( |
| 1374 const std::string& origin, |
| 1375 const std::string& proxy_server, |
| 1376 const std::string& status_line) const { |
| 1377 EXPECT_TRUE(on_tunnel_headers_received_called_); |
| 1378 EXPECT_TRUE(HostPortPair::FromString(origin).Equals( |
| 1379 on_tunnel_headers_received_origin_)); |
| 1380 EXPECT_TRUE(HostPortPair::FromString(proxy_server) |
| 1381 .Equals(on_tunnel_headers_received_proxy_server_)); |
| 1382 EXPECT_EQ(status_line, on_tunnel_headers_received_status_line_); |
| 1383 } |
| 1384 |
| 1385 void TestProxyDelegate::OnResolveProxy(const GURL& url, |
| 1386 int load_flags, |
| 1387 const ProxyService& proxy_service, |
| 1388 ProxyInfo* result) {} |
| 1389 |
| 1390 void TestProxyDelegate::OnTunnelConnectCompleted( |
| 1391 const HostPortPair& endpoint, |
| 1392 const HostPortPair& proxy_server, |
| 1393 int net_error) { |
| 1394 on_tunnel_request_completed_called_ = true; |
| 1395 on_tunnel_request_completed_endpoint_ = endpoint; |
| 1396 on_tunnel_request_completed_proxy_server_ = proxy_server; |
| 1397 } |
| 1398 |
| 1399 void TestProxyDelegate::OnFallback(const ProxyServer& bad_proxy, |
| 1400 int net_error) {} |
| 1401 |
| 1402 void TestProxyDelegate::OnBeforeSendHeaders(URLRequest* request, |
| 1403 const ProxyInfo& proxy_info, |
| 1404 HttpRequestHeaders* headers) {} |
| 1405 |
| 1406 void TestProxyDelegate::OnBeforeTunnelRequest( |
| 1407 const HostPortPair& proxy_server, |
| 1408 HttpRequestHeaders* extra_headers) { |
| 1409 on_before_tunnel_request_called_ = true; |
| 1410 if (extra_headers) |
| 1411 extra_headers->SetHeader("Foo", proxy_server.ToString()); |
| 1412 } |
| 1413 |
| 1414 void TestProxyDelegate::OnTunnelHeadersReceived( |
| 1415 const HostPortPair& origin, |
| 1416 const HostPortPair& proxy_server, |
| 1417 const HttpResponseHeaders& response_headers) { |
| 1418 on_tunnel_headers_received_called_ = true; |
| 1419 on_tunnel_headers_received_origin_ = origin; |
| 1420 on_tunnel_headers_received_proxy_server_ = proxy_server; |
| 1421 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine(); |
| 1422 } |
| 1423 |
| 1424 bool TestProxyDelegate::IsTrustedSpdyProxy( |
| 1425 const net::ProxyServer& proxy_server) { |
| 1426 return proxy_server.is_valid() && trusted_spdy_proxy_ == proxy_server; |
| 1427 } |
| 1428 |
1354 } // namespace net | 1429 } // namespace net |
OLD | NEW |