Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: net/http/http_proxy_client_socket_pool_unittest.cc

Issue 517693002: Add embedder-specific headers to HTTP CONNECT tunnel request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot to upload the new files Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_proxy_client_socket_pool_unittest.cc
diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc
index f2464919e3a72e53a9a3c66a76db1490d50b98f5..723a9bfa5d38b93a0e14032defd59ad3f66e1acd 100644
--- a/net/http/http_proxy_client_socket_pool_unittest.cc
+++ b/net/http/http_proxy_client_socket_pool_unittest.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/net_errors.h"
+#include "net/base/proxy_delegate.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_network_session.h"
#include "net/http/http_proxy_client_socket.h"
@@ -59,7 +60,8 @@ const char kHttpProxyHost[] = "httpproxy.example.com";
const char kHttpsProxyHost[] = "httpsproxy.example.com";
class HttpProxyClientSocketPoolTest
- : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> {
+ : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams>,
+ public net::ProxyDelegate {
protected:
HttpProxyClientSocketPoolTest()
: session_deps_(GetParam().protocol),
@@ -88,6 +90,8 @@ class HttpProxyClientSocketPoolTest
BoundNetLog().net_log()),
session_(CreateNetworkSession()),
http_proxy_histograms_("HttpProxyUnitTest"),
+ on_before_tunnel_request_called_(false),
+ on_before_tunnel_headers_received_called_(false),
spdy_util_(GetParam().protocol),
pool_(kMaxSockets,
kMaxSocketsPerGroup,
@@ -95,6 +99,7 @@ class HttpProxyClientSocketPoolTest
NULL,
&transport_socket_pool_,
&ssl_socket_pool_,
+ this,
NULL) {}
virtual ~HttpProxyClientSocketPoolTest() {
@@ -154,7 +159,8 @@ class HttpProxyClientSocketPoolTest
session_->http_auth_cache(),
session_->http_auth_handler_factory(),
session_->spdy_session_pool(),
- tunnel));
+ tunnel,
+ this));
}
scoped_refptr<HttpProxySocketParams> CreateTunnelParams() {
@@ -208,6 +214,43 @@ class HttpProxyClientSocketPoolTest
return transport_socket_pool_.last_request_priority();
}
+ // ProxyDelegate:
+ virtual void OnResolveProxy(const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) OVERRIDE {
+ }
+
+ virtual void OnFallback(const ProxyServer& bad_proxy,
+ int net_error) OVERRIDE {
+ }
+
+ virtual void OnBeforeSendHeaders(URLRequest* request,
+ const ProxyInfo& proxy_info,
+ HttpRequestHeaders* headers) OVERRIDE {
+ }
+
+ virtual void OnBeforeTunnelRequest(
+ const net::HostPortPair& proxy_server,
+ net::HttpRequestHeaders* extra_headers) OVERRIDE {
+ on_before_tunnel_request_called_ = true;
mmenke 2014/09/08 17:38:50 Should check this actually works (Maybe add a head
bengr 2014/09/09 01:28:49 Done.
+ }
+
+ virtual void OnTunnelHeadersReceived(
+ const net::HostPortPair& origin,
+ const net::HostPortPair& proxy_server,
+ const net::HttpResponseHeaders& response_headers) OVERRIDE {
mmenke 2014/09/08 17:38:50 Again, should validate these some way.
bengr 2014/09/09 01:28:49 Done.
+ on_before_tunnel_headers_received_called_ = true;
+ }
+
+ bool on_before_tunnel_request_called() {
+ return on_before_tunnel_request_called_;
+ }
+
+ bool on_before_tunnel_headers_received_called() {
mmenke 2014/09/08 17:38:50 These two should be const
bengr 2014/09/09 01:28:49 Done.
+ return on_before_tunnel_headers_received_called_;
+ }
+
private:
SpdySessionDependencies session_deps_;
@@ -220,6 +263,8 @@ class HttpProxyClientSocketPoolTest
const scoped_refptr<HttpNetworkSession> session_;
ClientSocketPoolHistograms http_proxy_histograms_;
+ bool on_before_tunnel_request_called_;
+ bool on_before_tunnel_headers_received_called_;
protected:
SpdyTestUtil spdy_util_;
@@ -264,6 +309,8 @@ TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) {
HttpProxyClientSocket* tunnel_socket =
static_cast<HttpProxyClientSocket*>(handle_.socket());
EXPECT_TRUE(tunnel_socket->IsConnected());
+ EXPECT_FALSE(on_before_tunnel_request_called());
+ EXPECT_FALSE(on_before_tunnel_headers_received_called());
}
// Make sure that HttpProxyConnectJob passes on its priority to its
@@ -363,6 +410,8 @@ TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) {
HttpProxyClientSocket* tunnel_socket =
static_cast<HttpProxyClientSocket*>(handle_.socket());
EXPECT_TRUE(tunnel_socket->IsConnected());
+ EXPECT_TRUE(on_before_tunnel_request_called());
+ EXPECT_TRUE(on_before_tunnel_headers_received_called());
}
TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) {

Powered by Google App Engine
This is Rietveld 408576698