summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/protocol')
-rw-r--r--netwerk/protocol/http/EarlyHintPreloader.cpp6
-rw-r--r--netwerk/protocol/http/Http2Session.cpp4
-rw-r--r--netwerk/protocol/http/Http2StreamTunnel.cpp4
-rw-r--r--netwerk/protocol/http/Http2StreamTunnel.h2
-rw-r--r--netwerk/protocol/http/nsHttpAtomList.h3
-rw-r--r--netwerk/protocol/http/nsHttpConnection.cpp29
-rw-r--r--netwerk/protocol/http/nsHttpConnection.h3
7 files changed, 39 insertions, 12 deletions
diff --git a/netwerk/protocol/http/EarlyHintPreloader.cpp b/netwerk/protocol/http/EarlyHintPreloader.cpp
index 4f06917c44..d21c65aaee 100644
--- a/netwerk/protocol/http/EarlyHintPreloader.cpp
+++ b/netwerk/protocol/http/EarlyHintPreloader.cpp
@@ -542,7 +542,7 @@ void EarlyHintPreloader::InvokeStreamListenerFunctions() {
nsTArray<StreamListenerFunction> streamListenerFunctions =
std::move(mStreamListenerFunctions);
- ForwardStreamListenerFunctions(streamListenerFunctions, mParent);
+ ForwardStreamListenerFunctions(std::move(streamListenerFunctions), mParent);
// We don't expect to get new stream listener functions added
// via re-entrancy. If this ever happens, we should understand
@@ -656,8 +656,8 @@ EarlyHintPreloader::OnDataAvailable(nsIRequest* aRequest,
nsresult rv = NS_ReadInputStreamToString(aInputStream, data, aCount);
NS_ENSURE_SUCCESS(rv, rv);
- mStreamListenerFunctions.AppendElement(
- AsVariant(OnDataAvailableParams{aRequest, data, aOffset, aCount}));
+ mStreamListenerFunctions.AppendElement(AsVariant(
+ OnDataAvailableParams{aRequest, std::move(data), aOffset, aCount}));
return NS_OK;
}
diff --git a/netwerk/protocol/http/Http2Session.cpp b/netwerk/protocol/http/Http2Session.cpp
index b9118d1898..d2236ab3ad 100644
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -574,8 +574,8 @@ already_AddRefed<nsHttpConnection> Http2Session::CreateTunnelStream(
this, mCurrentBrowserId, aHttpTransaction->ConnectionInfo(),
aIsWebSocket);
- RefPtr<nsHttpConnection> newConn =
- refStream->CreateHttpConnection(aHttpTransaction, aCallbacks, aRtt);
+ RefPtr<nsHttpConnection> newConn = refStream->CreateHttpConnection(
+ aHttpTransaction, aCallbacks, aRtt, aIsWebSocket);
mTunnelStreams.AppendElement(std::move(refStream));
return newConn.forget();
diff --git a/netwerk/protocol/http/Http2StreamTunnel.cpp b/netwerk/protocol/http/Http2StreamTunnel.cpp
index b3147fb732..4e0f05d58b 100644
--- a/netwerk/protocol/http/Http2StreamTunnel.cpp
+++ b/netwerk/protocol/http/Http2StreamTunnel.cpp
@@ -302,7 +302,7 @@ Http2StreamTunnel::GetStatus(nsresult* aStatus) {
already_AddRefed<nsHttpConnection> Http2StreamTunnel::CreateHttpConnection(
nsAHttpTransaction* httpTransaction, nsIInterfaceRequestor* aCallbacks,
- PRIntervalTime aRtt) {
+ PRIntervalTime aRtt, bool aIsWebSocket) {
mInput = new InputStreamTunnel(this);
mOutput = new OutputStreamTunnel(this);
RefPtr<nsHttpConnection> conn = new nsHttpConnection();
@@ -311,7 +311,7 @@ already_AddRefed<nsHttpConnection> Http2StreamTunnel::CreateHttpConnection(
nsresult rv =
conn->Init(httpTransaction->ConnectionInfo(),
gHttpHandler->ConnMgr()->MaxRequestDelay(), this, mInput,
- mOutput, true, NS_OK, aCallbacks, aRtt, false);
+ mOutput, true, NS_OK, aCallbacks, aRtt, aIsWebSocket);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
mTransaction = httpTransaction;
return conn.forget();
diff --git a/netwerk/protocol/http/Http2StreamTunnel.h b/netwerk/protocol/http/Http2StreamTunnel.h
index 6ad180c13b..78f0300f4c 100644
--- a/netwerk/protocol/http/Http2StreamTunnel.h
+++ b/netwerk/protocol/http/Http2StreamTunnel.h
@@ -39,7 +39,7 @@ class Http2StreamTunnel : public Http2StreamBase,
already_AddRefed<nsHttpConnection> CreateHttpConnection(
nsAHttpTransaction* httpTransaction, nsIInterfaceRequestor* aCallbacks,
- PRIntervalTime aRtt);
+ PRIntervalTime aRtt, bool aIsWebSocket);
nsHttpConnectionInfo* ConnectionInfo() override { return mConnectionInfo; }
diff --git a/netwerk/protocol/http/nsHttpAtomList.h b/netwerk/protocol/http/nsHttpAtomList.h
index af8882af0b..c80dfe6057 100644
--- a/netwerk/protocol/http/nsHttpAtomList.h
+++ b/netwerk/protocol/http/nsHttpAtomList.h
@@ -80,6 +80,9 @@ HTTP_ATOM(Range, "Range")
HTTP_ATOM(Referer, "Referer")
HTTP_ATOM(Referrer_Policy, "Referrer-Policy")
HTTP_ATOM(Retry_After, "Retry-After")
+HTTP_ATOM(Sec_WebSocket_Extensions, "Sec-WebSocket-Extensions")
+HTTP_ATOM(Sec_WebSocket_Protocol, "Sec-WebSocket-Protocol")
+HTTP_ATOM(Sec_WebSocket_Version, "Sec-WebSocket-Version")
HTTP_ATOM(Server, "Server")
HTTP_ATOM(Server_Timing, "Server-Timing")
HTTP_ATOM(Service_Worker_Allowed, "Service-Worker-Allowed")
diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp
index 07ca208acd..152a8348b4 100644
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -989,8 +989,11 @@ nsresult nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction* trans,
case HttpConnectionState::SETTING_UP_TUNNEL: {
nsHttpTransaction* trans = mTransaction->QueryHttpTransaction();
// Distinguish SETTING_UP_TUNNEL for proxy or websocket via proxy
+ // See bug 1848013. Do not call HandleTunnelResponse for a tunnel
+ // connection created for WebSocket.
if (trans && trans->IsWebsocketUpgrade() &&
- trans->GetProxyConnectResponseCode() == 200) {
+ (trans->GetProxyConnectResponseCode() == 200 ||
+ (mForWebSocket && mInSpdyTunnel))) {
HandleWebSocketResponse(requestHead, responseHead, responseStatus);
} else {
HandleTunnelResponse(responseStatus, reset);
@@ -1894,6 +1897,23 @@ nsresult nsHttpConnection::MakeConnectString(nsAHttpTransaction* trans,
request->SetRequestURI(requestURI);
request->SetHTTPS(trans->RequestHead()->IsHTTPS());
+
+ nsAutoCString val;
+ if (NS_SUCCEEDED(trans->RequestHead()->GetHeader(
+ nsHttp::Sec_WebSocket_Extensions, val))) {
+ rv = request->SetHeader(nsHttp::Sec_WebSocket_Extensions, val);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ }
+ if (NS_SUCCEEDED(trans->RequestHead()->GetHeader(
+ nsHttp::Sec_WebSocket_Protocol, val))) {
+ rv = request->SetHeader(nsHttp::Sec_WebSocket_Protocol, val);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ }
+ if (NS_SUCCEEDED(trans->RequestHead()->GetHeader(
+ nsHttp::Sec_WebSocket_Version, val))) {
+ rv = request->SetHeader(nsHttp::Sec_WebSocket_Version, val);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ }
} else {
request->SetRequestURI(result);
}
@@ -1934,8 +1954,8 @@ nsresult nsHttpConnection::MakeConnectString(nsAHttpTransaction* trans,
request->Flatten(result, false);
if (LOG1_ENABLED()) {
- LOG(("nsHttpConnection::MakeConnectString for transaction=%p [",
- trans->QueryHttpTransaction()));
+ LOG(("nsHttpConnection::MakeConnectString for transaction=%p h2ws=%d[",
+ trans->QueryHttpTransaction(), h2ws));
LogHeaders(result.BeginReading());
LOG(("]"));
}
@@ -2522,7 +2542,8 @@ nsresult nsHttpConnection::SetupProxyConnectStream() {
nsAutoCString buf;
nsHttpRequestHead request;
- nsresult rv = MakeConnectString(mTransaction, &request, buf, false,
+ nsresult rv = MakeConnectString(mTransaction, &request, buf,
+ mForWebSocket && mInSpdyTunnel,
mTransactionCaps & NS_HTTP_USE_RFP);
if (NS_FAILED(rv)) {
return rv;
diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h
index 401753f52c..6f00591a2e 100644
--- a/netwerk/protocol/http/nsHttpConnection.h
+++ b/netwerk/protocol/http/nsHttpConnection.h
@@ -362,6 +362,9 @@ class nsHttpConnection final : public HttpConnectionBase,
nsCOMPtr<nsISocketTransport> mSocketTransport;
+ // This flag indicates if the connection is used for WebSocket.
+ // - When true and mInSpdyTunnel is also true: WebSocket over HTTP/2.
+ // - When true and mInSpdyTunnel is false: WebSocket over HTTP/1.1.
bool mForWebSocket{false};
std::function<void()> mContinueHandshakeDone{nullptr};