diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-01-25 16:25:39 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-01-29 15:43:13 +0000 |
commit | 2b94bfe47ccb6c08047959d1c26e392919550e86 (patch) | |
tree | 4a9cb6fb333ac7e0e5bfbdd3a8faa219880e193d /chromium/net/http | |
parent | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (diff) | |
download | qtwebengine-chromium-2b94bfe47ccb6c08047959d1c26e392919550e86.tar.gz |
BASELINE: Update Chromium to 71.0.3578.140
Change-Id: Ia85516cc06e245e449ca8a6652242b8a1bcace74
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/net/http')
-rw-r--r-- | chromium/net/http/http_proxy_client_socket_pool_unittest.cc | 61 | ||||
-rw-r--r-- | chromium/net/http/http_proxy_client_socket_wrapper.cc | 25 |
2 files changed, 74 insertions, 12 deletions
diff --git a/chromium/net/http/http_proxy_client_socket_pool_unittest.cc b/chromium/net/http/http_proxy_client_socket_pool_unittest.cc index 2825f643022..51636757982 100644 --- a/chromium/net/http/http_proxy_client_socket_pool_unittest.cc +++ b/chromium/net/http/http_proxy_client_socket_pool_unittest.cc @@ -354,9 +354,6 @@ TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) { // so we skip this test for SPDY if (GetParam() == SPDY) return; - std::string proxy_host_port = GetParam() == HTTP - ? (kHttpProxyHost + std::string(":80")) - : (kHttpsProxyHost + std::string(":443")); std::string request = "CONNECT www.google.com:443 HTTP/1.1\r\n" "Host: www.google.com:443\r\n" @@ -382,9 +379,6 @@ TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) { } TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) { - std::string proxy_host_port = GetParam() == HTTP - ? (kHttpProxyHost + std::string(":80")) - : (kHttpsProxyHost + std::string(":443")); std::string request = "CONNECT www.google.com:443 HTTP/1.1\r\n" "Host: www.google.com:443\r\n" @@ -892,6 +886,10 @@ TEST_P(HttpProxyClientSocketPoolTest, // returned underlying TCP sockets. #if defined(OS_ANDROID) TEST_P(HttpProxyClientSocketPoolTest, Tag) { + // Socket tagging only supports Android without data reduction proxy, so only + // HTTP proxies are supported. + if (GetParam() != HTTP) + return; Initialize(base::span<MockRead>(), base::span<MockWrite>(), base::span<MockRead>(), base::span<MockWrite>()); SocketTag tag1(SocketTag::UNSET_UID, 0x12345678); @@ -924,6 +922,57 @@ TEST_P(HttpProxyClientSocketPoolTest, Tag) { handle_.socket()->Disconnect(); handle_.Reset(); } + +TEST_P(HttpProxyClientSocketPoolTest, TagWithProxy) { + // Socket tagging only supports Android without data reduction proxy, so only + // HTTP proxies are supported. + if (GetParam() != HTTP) + return; + std::string request = + "CONNECT www.google.com:443 HTTP/1.1\r\n" + "Host: www.google.com:443\r\n" + "Proxy-Connection: keep-alive\r\n" + "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"; + MockWrite writes[] = { + MockWrite(SYNCHRONOUS, 0, request.c_str()), + }; + MockRead reads[] = { + MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 Connection Established\r\n\r\n"), + }; + + Initialize(reads, writes, base::span<MockRead>(), base::span<MockWrite>()); + AddAuthToCache(); + + SocketTag tag1(SocketTag::UNSET_UID, 0x12345678); + SocketTag tag2(getuid(), 0x87654321); + + // Verify requested socket is tagged properly. + int rv = + handle_.Init("a", CreateTunnelParams(), LOW, tag1, + ClientSocketPool::RespectLimits::ENABLED, + CompletionOnceCallback(), pool_.get(), NetLogWithSource()); + EXPECT_THAT(rv, IsOk()); + EXPECT_TRUE(handle_.is_initialized()); + ASSERT_TRUE(handle_.socket()); + EXPECT_TRUE(handle_.socket()->IsConnected()); + EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag1); + EXPECT_TRUE( + socket_factory()->GetLastProducedTCPSocket()->tagged_before_connected()); + + // Verify reused socket is retagged properly. + StreamSocket* socket = handle_.socket(); + handle_.Reset(); + rv = handle_.Init("a", CreateNoTunnelParams(), LOW, tag2, + ClientSocketPool::RespectLimits::ENABLED, + CompletionOnceCallback(), pool_.get(), NetLogWithSource()); + EXPECT_THAT(rv, IsOk()); + EXPECT_TRUE(handle_.socket()); + EXPECT_TRUE(handle_.socket()->IsConnected()); + EXPECT_EQ(handle_.socket(), socket); + EXPECT_EQ(socket_factory()->GetLastProducedTCPSocket()->tag(), tag2); + handle_.socket()->Disconnect(); + handle_.Reset(); +} #endif } // namespace net diff --git a/chromium/net/http/http_proxy_client_socket_wrapper.cc b/chromium/net/http/http_proxy_client_socket_wrapper.cc index f1cad81680a..b8361830009 100644 --- a/chromium/net/http/http_proxy_client_socket_wrapper.cc +++ b/chromium/net/http/http_proxy_client_socket_wrapper.cc @@ -285,12 +285,25 @@ int64_t HttpProxyClientSocketWrapper::GetTotalReceivedBytes() const { } void HttpProxyClientSocketWrapper::ApplySocketTag(const SocketTag& tag) { - // HttpProxyClientSocketPool only tags once connected, when transport_socket_ - // is set. Socket tagging is not supported with tunneling. Socket tagging is - // also not supported with proxy auth so ApplySocketTag() won't be called with - // a specific (non-default) tag when transport_socket_ is cleared by - // RestartWithAuth(). - if (tunnel_ || !transport_socket_) { + // Applying a socket tag to an HttpProxyClientSocketWrapper is done by simply + // applying the socket tag to the underlying socket. + + // In the case of a connection to the proxy using HTTP/2 or HTTP/3 where the + // underlying socket may multiplex multiple streams, applying this request's + // socket tag to the multiplexed session would incorrectly apply the socket + // tag to all mutliplexed streams. In reality this would hit the CHECK(false) + // in QuicProxyClientSocket::ApplySocketTag() or + // SpdyProxyClientSocket::ApplySocketTag(). Fortunately socket tagging is only + // supported on Android without the data reduction proxy, so only simple HTTP + // proxies are supported, so proxies won't be using HTTP/2 or HTTP/3. Detect + // this case (|ssl_params_| must be set for HTTP/2 and HTTP/3 proxies) and + // enforce that a specific (non-default) tag isn't being applied. + if (ssl_params_ || + // Android also doesn't support proxy auth, so RestartWithAuth() should't + // be called so |transport_socket_| shouldn't be cleared. If + // |transport_socket_| is cleared, enforce that a specific (non-default) + // tag isn't being applied. + !transport_socket_) { CHECK(tag == SocketTag()); } else { transport_socket_->ApplySocketTag(tag); |