Bug 1754004 - Part 13: Relax interface check in nsHttpTransaction, r=necko-reviewers,kershaw

Previously, the check when reporting progress from a nsHttpTransaction would
always report no progress when a non-seekable input stream is used as the
request data stream. Before Part 5, we incorrectly always reported the
nsBufferedStream which we wrap request streams with as seekable, meaning that
this check would pass and the progress reporting would work.

This change relaxes the check to instead check for nsITellableStream which is
actually guaranteed by the nsBufferedStream wrapper, and provides the Tell
method being used.

Differential Revision: https://phabricator.services.mozilla.com/D144450
This commit is contained in:
Nika Layzell 2022-05-10 22:27:47 +00:00
Родитель 7e0bd4473f
Коммит 94e20acc6a
1 изменённых файлов: 9 добавлений и 4 удалений

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

@ -660,16 +660,21 @@ void nsHttpTransaction::OnTransportStatus(nsITransport* transport,
return;
}
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mRequestStream);
if (!seekable) {
nsCOMPtr<nsITellableStream> tellable = do_QueryInterface(mRequestStream);
if (!tellable) {
LOG1(
("nsHttpTransaction::OnTransportStatus %p "
"SENDING_TO without seekable request stream\n",
"SENDING_TO without tellable request stream\n",
this));
MOZ_ASSERT(
!mRequestStream,
"mRequestStream should be tellable as it was wrapped in "
"nsBufferedInputStream, which provides the tellable interface even "
"when wrapping non-tellable streams.");
progress = 0;
} else {
int64_t prog = 0;
seekable->Tell(&prog);
tellable->Tell(&prog);
progress = prog;
}