Set QUIC stream priority in HttpProxyClientSocketWrapper when doing QUIC proxy tunnel
Change-Id: I45fd9150165dd2c55b9e5c3cdb639853b7e84532
Reviewed-on: https://chromium-review.googlesource.com/879725
Reviewed-by: Ryan Hamilton <[email protected]>
Commit-Queue: Yixin Wang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#531344}
diff --git a/net/http/http_proxy_client_socket_wrapper.cc b/net/http/http_proxy_client_socket_wrapper.cc
index f34f0f9..f9fe475d 100644
--- a/net/http/http_proxy_client_socket_wrapper.cc
+++ b/net/http/http_proxy_client_socket_wrapper.cc
@@ -17,6 +17,7 @@
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_source_type.h"
+#include "net/quic/chromium/quic_http_utils.h"
#include "net/quic/chromium/quic_proxy_client_socket.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/socket_tag.h"
@@ -659,6 +660,9 @@
std::unique_ptr<QuicChromiumClientStream::Handle> quic_stream =
quic_session_->ReleaseStream();
+ SpdyPriority spdy_priority = ConvertRequestPriorityToQuicPriority(priority_);
+ quic_stream->SetPriority(spdy_priority);
+
transport_socket_.reset(new QuicProxyClientSocket(
std::move(quic_stream), std::move(quic_session_), user_agent_, endpoint_,
net_log_, http_auth_controller_.get()));
diff --git a/net/quic/chromium/quic_network_transaction_unittest.cc b/net/quic/chromium/quic_network_transaction_unittest.cc
index cf42d5c..84239ef 100644
--- a/net/quic/chromium/quic_network_transaction_unittest.cc
+++ b/net/quic/chromium/quic_network_transaction_unittest.cc
@@ -6628,6 +6628,41 @@
EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
}
+// Makes sure the CONNECT request packet for a QUIC proxy contains the correct
+// HTTP/2 stream dependency and weights given the request priority.
+TEST_P(QuicNetworkTransactionTest, QuicProxyRequestPriority) {
+ session_params_.enable_quic = true;
+ proxy_resolution_service_ = ProxyResolutionService::CreateFixedFromPacResult(
+ "QUIC proxy.example.org:70");
+
+ const RequestPriority request_priority = MEDIUM;
+
+ MockQuicData mock_quic_data;
+ QuicStreamOffset header_stream_offset = 0;
+ mock_quic_data.AddWrite(
+ ConstructInitialSettingsPacket(1, &header_stream_offset));
+ mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket(
+ 2, GetNthClientInitiatedStreamId(0), true, false, request_priority,
+ ConnectRequestHeaders("mail.example.org:443"), 0, &header_stream_offset));
+ // Return an error, so the transaction stops here (this test isn't interested
+ // in the rest).
+ mock_quic_data.AddRead(ASYNC, ERR_CONNECTION_FAILED);
+
+ mock_quic_data.AddSocketDataToFactory(&socket_factory_);
+
+ CreateSession();
+
+ request_.url = GURL("https://mail.example.org/");
+ HttpNetworkTransaction trans(request_priority, session_.get());
+ TestCompletionCallback callback;
+ int rv = trans.Start(&request_, callback.callback(), net_log_.bound());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, callback.WaitForResult());
+
+ EXPECT_TRUE(mock_quic_data.AllReadDataConsumed());
+ EXPECT_TRUE(mock_quic_data.AllWriteDataConsumed());
+}
+
// Test the request-challenge-retry sequence for basic auth, over a QUIC
// connection when setting up a QUIC proxy tunnel.
TEST_P(QuicNetworkTransactionTest, QuicProxyAuth) {