Bug 1883618 - OnDataAvailable coming from brotli decoder has wrong offset r=jesup,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D203596
This commit is contained in:
Valentin Gosu 2024-03-06 17:46:58 +00:00
parent d465d77381
commit 6c5a3476d1

View File

@ -264,6 +264,7 @@ nsresult nsHTTPCompressConv::BrotliHandler(nsIInputStream* stream,
reinterpret_cast<const char*>(outBuffer.get()), outSize))) {
return self->mBrotli->mStatus;
}
self->mBrotli->mSourceOffset += outSize;
}
// See bug 1759745. If the decoder has more output data, take it.
@ -276,6 +277,7 @@ nsresult nsHTTPCompressConv::BrotliHandler(nsIInputStream* stream,
outSize))) {
return self->mBrotli->mStatus;
}
self->mBrotli->mSourceOffset += outSize;
}
if (res == BROTLI_DECODER_RESULT_SUCCESS ||
@ -295,7 +297,9 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request, nsIInputStream* iStr,
uint64_t aSourceOffset, uint32_t aCount) {
nsresult rv = NS_ERROR_INVALID_CONTENT_ENCODING;
uint32_t streamLen = aCount;
LOG(("nsHttpCompressConv %p OnDataAvailable %d", this, aCount));
LOG(("nsHttpCompressConv %p OnDataAvailable aSourceOffset:%" PRIu64
" count:%u",
this, aSourceOffset, aCount));
if (streamLen == 0) {
NS_ERROR("count of zero passed to OnDataAvailable");
@ -561,6 +565,9 @@ nsresult nsHTTPCompressConv::do_OnDataAvailable(nsIRequest* request,
MutexAutoLock lock(mMutex);
listener = mListener;
}
LOG(("nsHTTPCompressConv::do_OnDataAvailable req:%p offset: offset:%" PRIu64
"count:%u",
request, offset, count));
nsresult rv = listener->OnDataAvailable(request, mStream, offset, count);
// Make sure the stream no longer references |buffer| in case our listener