Bug 1754737 - We do not need to keep info about the use of a tunnel in the state. r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D138890
This commit is contained in:
Dragana Damjanovic 2022-02-22 11:21:39 +00:00
Родитель 0248b17c59
Коммит ccd00cf1aa
2 изменённых файлов: 8 добавлений и 14 удалений

Просмотреть файл

@ -1227,7 +1227,7 @@ void nsHttpConnection::HandleTunnelResponse(uint16_t responseStatus,
// socket write request.
if (responseStatus == 200) {
ChangeState(HttpConnectionState::TUNNEL_DONE);
ChangeState(HttpConnectionState::REQUEST);
}
mProxyConnectStream = nullptr;
bool isHttps = mTransaction ? mTransaction->ConnectionInfo()->EndToEndSSL()
@ -1793,7 +1793,7 @@ nsresult nsHttpConnection::OnSocketWritable() {
uint32_t writeAttempts = 0;
if (mTransactionCaps & NS_HTTP_CONNECT_ONLY) {
if (!TunnelUsed()) {
if (!mConnInfo->UsingConnect()) {
// A CONNECT has been requested for this connection but will never
// be performed. This should never happen.
MOZ_ASSERT(false, "proxy connect will never happen");
@ -1801,7 +1801,7 @@ nsresult nsHttpConnection::OnSocketWritable() {
return NS_ERROR_FAILURE;
}
if (TunnelCompleted()) {
if (mState == HttpConnectionState::REQUEST) {
// Don't need to check this each write attempt since it is only
// updated after OnSocketWritable completes.
// We've already done primary tls (if needed) and sent our CONNECT.
@ -1965,7 +1965,7 @@ nsresult nsHttpConnection::OnSocketReadable() {
// Reset mResponseTimeoutEnabled to stop response timeout checks.
mResponseTimeoutEnabled = false;
if ((mTransactionCaps & NS_HTTP_CONNECT_ONLY) && !TunnelUsed()) {
if ((mTransactionCaps & NS_HTTP_CONNECT_ONLY) && !mConnInfo->UsingConnect()) {
// A CONNECT has been requested for this connection but will never
// be performed. This should never happen.
MOZ_ASSERT(false, "proxy connect will never happen");
@ -2688,7 +2688,7 @@ void nsHttpConnection::SetTunnelSetupDone() {
MOZ_ASSERT(mProxyConnectStream);
MOZ_ASSERT(mState == HttpConnectionState::SETTING_UP_TUNNEL);
ChangeState(HttpConnectionState::TUNNEL_DONE);
ChangeState(HttpConnectionState::REQUEST);
mProxyConnectStream = nullptr;
}
@ -2697,7 +2697,7 @@ nsresult nsHttpConnection::CheckTunnelIsNeeded() {
case HttpConnectionState::UNINITIALIZED: {
// This is is called first time. Check if we need a tunnel.
if (!mTransaction->ConnectionInfo()->UsingConnect()) {
ChangeState(HttpConnectionState::TUNNEL_NOT_USED);
ChangeState(HttpConnectionState::REQUEST);
return NS_OK;
}
ChangeState(HttpConnectionState::SETTING_UP_TUNNEL);
@ -2713,8 +2713,7 @@ nsresult nsHttpConnection::CheckTunnelIsNeeded() {
}
return rv;
}
case HttpConnectionState::TUNNEL_DONE:
case HttpConnectionState::TUNNEL_NOT_USED:
case HttpConnectionState::REQUEST:
return NS_OK;
}
}

Просмотреть файл

@ -202,17 +202,12 @@ class nsHttpConnection final : public HttpConnectionBase,
enum HttpConnectionState {
UNINITIALIZED,
SETTING_UP_TUNNEL,
TUNNEL_DONE,
TUNNEL_NOT_USED,
REQUEST,
} mState{HttpConnectionState::UNINITIALIZED};
void ChangeState(HttpConnectionState newState);
// Tunnel retated functions:
bool TunnelSetupInProgress() { return mState == SETTING_UP_TUNNEL; }
bool TunnelUsed() {
return mState == SETTING_UP_TUNNEL || mState == TUNNEL_DONE;
}
bool TunnelCompleted() { return mState == TUNNEL_DONE; }
void SetTunnelSetupDone();
nsresult CheckTunnelIsNeeded();
nsresult SetupProxyConnectStream();