mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1249904: Use content-range values to determine length if content-length is unknown. r=roc
While currently unused, the functionality of mByteRange was preserved. To avoid unforeseen regressions, we only error on an invalid Content-Range response if mByteRange was set, otherwise the error is ignored and code proceed as before. MozReview-Commit-ID: BRiO633uTh7
This commit is contained in:
parent
2db708974f
commit
05ebec7baa
@ -236,14 +236,20 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
|
||||
// Content-Range header tells us otherwise.
|
||||
bool boundedSeekLimit = true;
|
||||
// Check response code for byte-range requests (seeking, chunk requests).
|
||||
if (!mByteRange.IsEmpty() && (responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
|
||||
if (responseStatus == HTTP_PARTIAL_RESPONSE_CODE) {
|
||||
// Parse Content-Range header.
|
||||
int64_t rangeStart = 0;
|
||||
int64_t rangeEnd = 0;
|
||||
int64_t rangeTotal = 0;
|
||||
rv = ParseContentRangeHeader(hc, rangeStart, rangeEnd, rangeTotal);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Content-Range header text should be parse-able.
|
||||
|
||||
// We received 'Content-Range', so the server accepts range requests.
|
||||
acceptsRanges = NS_SUCCEEDED(rv);
|
||||
|
||||
if (!mByteRange.IsEmpty()) {
|
||||
if (!acceptsRanges) {
|
||||
// Content-Range header text should be parse-able when processing a
|
||||
// range requests.
|
||||
CMLOG("Error processing \'Content-Range' for "
|
||||
"HTTP_PARTIAL_RESPONSE_CODE: rv[%x] channel[%p] decoder[%p]",
|
||||
rv, hc.get(), mCallback.get());
|
||||
@ -251,7 +257,6 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
|
||||
CloseChannel();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Give some warnings if the ranges are unexpected.
|
||||
// XXX These could be error conditions.
|
||||
NS_WARN_IF_FALSE(mByteRange.mStart == rangeStart,
|
||||
@ -269,10 +274,11 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
|
||||
mCacheStream.NotifyDataLength(rangeTotal);
|
||||
}
|
||||
mCacheStream.NotifyDataStarted(rangeStart);
|
||||
|
||||
mOffset = rangeStart;
|
||||
// We received 'Content-Range', so the server accepts range requests.
|
||||
acceptsRanges = true;
|
||||
} else if (contentLength < 0 && acceptsRanges && rangeTotal > 0) {
|
||||
// Content-Length was unknown, use content-range instead.
|
||||
contentLength = rangeTotal;
|
||||
}
|
||||
} else if (((mOffset > 0) || !mByteRange.IsEmpty())
|
||||
&& (responseStatus == HTTP_OK_CODE)) {
|
||||
// If we get an OK response but we were seeking, or requesting a byte
|
||||
@ -283,13 +289,12 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
|
||||
|
||||
// The server claimed it supported range requests. It lied.
|
||||
acceptsRanges = false;
|
||||
} else if (mOffset == 0 &&
|
||||
}
|
||||
if (mOffset == 0 && contentLength >= 0 &&
|
||||
(responseStatus == HTTP_OK_CODE ||
|
||||
responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
|
||||
if (contentLength >= 0) {
|
||||
mCacheStream.NotifyDataLength(contentLength);
|
||||
}
|
||||
}
|
||||
// XXX we probably should examine the Content-Range header in case
|
||||
// the server gave us a range which is not quite what we asked for
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user