Only perform range requests for identity Content-Encoding
This commit is contained in:
parent
8e4d9e9aa0
commit
e0d4b322cf
@ -692,17 +692,34 @@ PdfStreamConverter.prototype = {
|
||||
// nsIRequestObserver::onStartRequest
|
||||
onStartRequest: function(aRequest, aContext) {
|
||||
// Setup the request so we can use it below.
|
||||
var acceptRanges = false;
|
||||
var isHttpRequest = false;
|
||||
try {
|
||||
aRequest.QueryInterface(Ci.nsIHttpChannel);
|
||||
if (aRequest.getResponseHeader('Accept-Ranges') === 'bytes') {
|
||||
var hash = aRequest.URI.ref;
|
||||
acceptRanges = hash.indexOf('disableRange=true') < 0;
|
||||
}
|
||||
isHttpRequest = true;
|
||||
} catch (e) {}
|
||||
|
||||
var rangeRequest = false;
|
||||
if (isHttpRequest) {
|
||||
var contentEncoding = 'identity';
|
||||
try {
|
||||
contentEncoding = aRequest.getResponseHeader('Content-Encoding');
|
||||
} catch (e) {}
|
||||
|
||||
var acceptRanges;
|
||||
try {
|
||||
acceptRanges = aRequest.getResponseHeader('Accept-Ranges');
|
||||
} catch (e) {}
|
||||
|
||||
var hash = aRequest.URI.ref;
|
||||
rangeRequest = contentEncoding === 'identity' &&
|
||||
acceptRanges === 'bytes' &&
|
||||
hash.indexOf('disableRange=true') < 0;
|
||||
}
|
||||
|
||||
aRequest.QueryInterface(Ci.nsIChannel);
|
||||
|
||||
aRequest.QueryInterface(Ci.nsIWritablePropertyBag);
|
||||
|
||||
var contentDispositionFilename;
|
||||
try {
|
||||
contentDispositionFilename = aRequest.contentDispositionFilename;
|
||||
@ -712,7 +729,7 @@ PdfStreamConverter.prototype = {
|
||||
aRequest.setProperty('contentType', aRequest.contentType);
|
||||
aRequest.contentType = 'text/html';
|
||||
|
||||
if (!acceptRanges) {
|
||||
if (!rangeRequest) {
|
||||
// Creating storage for PDF data
|
||||
var contentLength = aRequest.contentLength;
|
||||
this.dataListener = new PdfDataListener(contentLength);
|
||||
@ -750,7 +767,7 @@ PdfStreamConverter.prototype = {
|
||||
// Double check the url is still the correct one.
|
||||
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
||||
var actions;
|
||||
if (acceptRanges) {
|
||||
if (rangeRequest) {
|
||||
// We are going to be issuing range requests, so cancel the
|
||||
// original request
|
||||
aRequest.resume();
|
||||
|
@ -183,6 +183,12 @@ var WorkerMessageHandler = {
|
||||
return;
|
||||
}
|
||||
|
||||
var contentEncoding =
|
||||
fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
|
||||
if (contentEncoding !== 'identity') {
|
||||
return;
|
||||
}
|
||||
|
||||
var length = fullRequestXhr.getResponseHeader('Content-Length');
|
||||
length = parseInt(length, 10);
|
||||
if (!isInt(length)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user