browser(firefox): fix HTTP->HTTPS fallback for refused connection (#11123)

In this case, there's no protocol version that we can extract for
nsIHttpChannel.

The code that does the redirect is here: 7f3d9fce41/docshell/base/nsDocShell.cpp (L6079-L6095)

To trigger this codepath, we'd need to run test inside a special
docker container that has https server running on the 443 port. We lack
infrastructure for this kind of tests (but it'll be cool to have it).

References #11118
This commit is contained in:
Andrey Lushnikov 2021-12-28 13:23:53 -07:00 committed by GitHub
parent dadb5cbc30
commit fba29aa319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 8 deletions

View File

@ -1,2 +1,2 @@
1311
Changed: lushnikov@chromium.org Tue Dec 14 23:27:53 PST 2021
1312
Changed: lushnikov@chromium.org Tue Dec 28 13:12:02 MST 2021

View File

@ -554,12 +554,18 @@ class NetworkRequest {
_sendOnRequestFinished() {
const pageNetwork = this._pageNetwork;
if (pageNetwork) {
let protocolVersion = undefined;
try {
protocolVersion = this.httpChannel.protocolVersion;
} catch (e) {
// protocolVersion is unavailable in certain cases.
};
pageNetwork.emit(PageNetwork.Events.RequestFinished, {
requestId: this.requestId,
responseEndTime: this.httpChannel.responseEndTime,
transferSize: this.httpChannel.transferSize,
encodedBodySize: this.httpChannel.encodedBodySize,
protocolVersion: this.httpChannel.protocolVersion,
protocolVersion,
}, this._frameId);
}
this._networkObserver._channelToRequest.delete(this.httpChannel);

View File

@ -503,7 +503,7 @@ const Network = {
responseEndTime: t.Number,
transferSize: t.Number,
encodedBodySize: t.Number,
protocolVersion: t.String,
protocolVersion: t.Optional(t.String),
},
'requestFailed': {
requestId: t.String,

View File

@ -1,2 +1,2 @@
1311
Changed: lushnikov@chromium.org Tue Dec 14 23:26:10 PST 2021
1312
Changed: lushnikov@chromium.org Tue Dec 28 13:12:02 MST 2021

View File

@ -554,12 +554,18 @@ class NetworkRequest {
_sendOnRequestFinished() {
const pageNetwork = this._pageNetwork;
if (pageNetwork) {
let protocolVersion = undefined;
try {
protocolVersion = this.httpChannel.protocolVersion;
} catch (e) {
// protocolVersion is unavailable in certain cases.
};
pageNetwork.emit(PageNetwork.Events.RequestFinished, {
requestId: this.requestId,
responseEndTime: this.httpChannel.responseEndTime,
transferSize: this.httpChannel.transferSize,
encodedBodySize: this.httpChannel.encodedBodySize,
protocolVersion: this.httpChannel.protocolVersion,
protocolVersion,
}, this._frameId);
}
this._networkObserver._channelToRequest.delete(this.httpChannel);

View File

@ -503,7 +503,7 @@ const Network = {
responseEndTime: t.Number,
transferSize: t.Number,
encodedBodySize: t.Number,
protocolVersion: t.String,
protocolVersion: t.Optional(t.String),
},
'requestFailed': {
requestId: t.String,