forked from mirrors/gecko-dev
Bug 1811477 - Make sure we handle websocket over Http/2 with a Http/2 proxy properly, r=edgul,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D167547
This commit is contained in:
parent
e1b256b25c
commit
bd28457c2f
6 changed files with 24 additions and 18 deletions
|
|
@ -86,7 +86,7 @@ class ASpdySession : public nsAHttpTransaction {
|
|||
|
||||
virtual already_AddRefed<mozilla::net::nsHttpConnection> CreateTunnelStream(
|
||||
nsAHttpTransaction* aHttpTransaction, nsIInterfaceRequestor* aCallbacks,
|
||||
PRIntervalTime aRtt) = 0;
|
||||
PRIntervalTime aRtt, bool aIsWebSocket = false) = 0;
|
||||
};
|
||||
|
||||
using ALPNCallback = bool (*)(nsITLSSocketControl*);
|
||||
|
|
|
|||
|
|
@ -552,9 +552,10 @@ void Http2Session::CreateStream(nsAHttpTransaction* aHttpTransaction,
|
|||
|
||||
already_AddRefed<nsHttpConnection> Http2Session::CreateTunnelStream(
|
||||
nsAHttpTransaction* aHttpTransaction, nsIInterfaceRequestor* aCallbacks,
|
||||
PRIntervalTime aRtt) {
|
||||
PRIntervalTime aRtt, bool aIsWebSocket) {
|
||||
RefPtr<Http2StreamTunnel> refStream = CreateTunnelStreamFromConnInfo(
|
||||
this, mCurrentTopBrowsingContextId, aHttpTransaction->ConnectionInfo());
|
||||
this, mCurrentTopBrowsingContextId, aHttpTransaction->ConnectionInfo(),
|
||||
aIsWebSocket);
|
||||
|
||||
RefPtr<nsHttpConnection> newConn =
|
||||
refStream->CreateHttpConnection(aHttpTransaction, aCallbacks, aRtt);
|
||||
|
|
@ -1165,18 +1166,22 @@ bool Http2Session::VerifyStream(Http2StreamBase* aStream,
|
|||
|
||||
// static
|
||||
Http2StreamTunnel* Http2Session::CreateTunnelStreamFromConnInfo(
|
||||
Http2Session* session, uint64_t bcId, nsHttpConnectionInfo* info) {
|
||||
Http2Session* session, uint64_t bcId, nsHttpConnectionInfo* info,
|
||||
bool isWebSocket) {
|
||||
MOZ_ASSERT(info);
|
||||
MOZ_ASSERT(session);
|
||||
if (info->UsingHttpProxy() && info->UsingConnect()) {
|
||||
LOG(("Http2Session creating Http2StreamTunnel"));
|
||||
return new Http2StreamTunnel(session, nsISupportsPriority::PRIORITY_NORMAL,
|
||||
bcId, info);
|
||||
|
||||
if (isWebSocket) {
|
||||
LOG(("Http2Session creating Http2StreamWebSocket"));
|
||||
MOZ_ASSERT(session->GetWebSocketSupport() == WebSocketSupport::SUPPORTED);
|
||||
return new Http2StreamWebSocket(
|
||||
session, nsISupportsPriority::PRIORITY_NORMAL, bcId, info);
|
||||
}
|
||||
MOZ_ASSERT(session->GetWebSocketSupport() == WebSocketSupport::SUPPORTED);
|
||||
LOG(("Http2Session creating Http2StreamWebSocket"));
|
||||
return new Http2StreamWebSocket(session, nsISupportsPriority::PRIORITY_NORMAL,
|
||||
bcId, info);
|
||||
|
||||
MOZ_ASSERT(info->UsingHttpProxy() && info->UsingConnect());
|
||||
LOG(("Http2Session creating Http2StreamTunnel"));
|
||||
return new Http2StreamTunnel(session, nsISupportsPriority::PRIORITY_NORMAL,
|
||||
bcId, info);
|
||||
}
|
||||
|
||||
void Http2Session::CleanupStream(Http2StreamBase* aStream, nsresult aResult,
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ class Http2Session final : public ASpdySession,
|
|||
|
||||
already_AddRefed<nsHttpConnection> CreateTunnelStream(
|
||||
nsAHttpTransaction* aHttpTransaction, nsIInterfaceRequestor* aCallbacks,
|
||||
PRIntervalTime aRtt) override;
|
||||
PRIntervalTime aRtt, bool aIsWebSocket = false) override;
|
||||
|
||||
void CleanupStream(Http2StreamBase*, nsresult, errorType);
|
||||
|
||||
|
|
@ -303,7 +303,8 @@ class Http2Session final : public ASpdySession,
|
|||
bool attemptingEarlyData);
|
||||
|
||||
static Http2StreamTunnel* CreateTunnelStreamFromConnInfo(
|
||||
Http2Session* session, uint64_t bcId, nsHttpConnectionInfo* connInfo);
|
||||
Http2Session* session, uint64_t bcId, nsHttpConnectionInfo* connInfo,
|
||||
bool isWebSocket);
|
||||
|
||||
// These internal states do not correspond to the states of the HTTP/2
|
||||
// specification
|
||||
|
|
|
|||
|
|
@ -653,8 +653,8 @@ nsresult nsHttpConnection::CreateTunnelStream(
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
RefPtr<nsHttpConnection> conn =
|
||||
mSpdySession->CreateTunnelStream(httpTransaction, mCallbacks, mRtt);
|
||||
RefPtr<nsHttpConnection> conn = mSpdySession->CreateTunnelStream(
|
||||
httpTransaction, mCallbacks, mRtt, aIsWebSocket);
|
||||
// We need to store the refrence of the Http2Session in the tunneled
|
||||
// connection, so when nsHttpConnection::DontReuse is called the Http2Session
|
||||
// can't be reused.
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ add_task(async function test_h2_ws_with_h2_proxy() {
|
|||
let proxy = new NodeHTTP2ProxyServer();
|
||||
await proxy.start(); // start and register proxy "filter"
|
||||
|
||||
let wss = new NodeWebSocketServer();
|
||||
let wss = new NodeWebSocketHttp2Server();
|
||||
await wss.start(); // init port
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ async function test_h2_ws_with_h2_proxy() {
|
|||
let proxy = new NodeHTTP2ProxyServer();
|
||||
await proxy.start(); // start and register proxy "filter"
|
||||
|
||||
let wss = new NodeWebSocketServer();
|
||||
let wss = new NodeWebSocketHttp2Server();
|
||||
await wss.start(); // init port
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue