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 коммит произвёл GitHub
Родитель dadb5cbc30
Коммит fba29aa319
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 20 добавлений и 8 удалений

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

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

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

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

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

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

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

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

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

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

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

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