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