Skip to content

Commit

Permalink
Chore: remove x-box-accept-encoding header to prevent OPTIONS call (#841
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JustinHoldstock authored Sep 7, 2018
1 parent cba2f66 commit 8ebf984
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 40 deletions.
4 changes: 0 additions & 4 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export const X_REP_HINT_IMAGE = '[jpg?dimensions=2048x2048,png?dimensions=2048x2
export const X_REP_HINT_VIDEO_DASH = '[dash,mp4][filmstrip]';
export const X_REP_HINT_VIDEO_MP4 = '[mp4]';

// X-Box-Accept-Encoding Header for requesting non-gzipped representation
export const X_BOX_ACCEPT_ENCODING_HEADER = 'x-box-accept-encoding';
export const X_BOX_ACCEPT_ENCODING_IDENTITY = 'identity';

export const PDFJS_CSS_UNITS = 96.0 / 72.0; // Should match CSS_UNITS in pdf_viewer.js
export const PDFJS_MAX_AUTO_SCALE = 1.25; // Should match MAX_AUTO_SCALE in pdf_viewer.js
export const PDFJS_WIDTH_PADDING_PX = 40; // Should match SCROLLBAR_PADDING in pdf_viewer.js
Expand Down
10 changes: 1 addition & 9 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import {
DOC_STATIC_ASSETS_VERSION,
PERMISSION_DOWNLOAD,
PRELOAD_REP_NAME,
STATUS_SUCCESS,
X_BOX_ACCEPT_ENCODING_HEADER,
X_BOX_ACCEPT_ENCODING_IDENTITY
STATUS_SUCCESS
} from '../../constants';
import { checkPermission, getRepresentation } from '../../file';
import { get, createAssetUrlCreator, getMidpoint, getDistance, getClosestPageToPinch } from '../../util';
Expand Down Expand Up @@ -585,12 +583,6 @@ class DocBaseViewer extends BaseViewer {
};
}

// If range requests are enabled, request the non-gzip compressed version of the representation
if (!PDFJS.disableRange) {
docInitParams.httpHeaders = docInitParams.httpHeaders || {};
docInitParams.httpHeaders[X_BOX_ACCEPT_ENCODING_HEADER] = X_BOX_ACCEPT_ENCODING_IDENTITY;
}

// Start timing document load
this.startLoadTimer();

Expand Down
28 changes: 1 addition & 27 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import {
PERMISSION_DOWNLOAD,
STATUS_ERROR,
STATUS_PENDING,
STATUS_SUCCESS,
X_BOX_ACCEPT_ENCODING_HEADER,
X_BOX_ACCEPT_ENCODING_IDENTITY
STATUS_SUCCESS
} from '../../../constants';

import { ICON_PRINT_CHECKMARK } from '../../../icons/icons';
Expand Down Expand Up @@ -922,30 +920,6 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
});
});

it('should set a x-box-accept-encoding header when range requests are enabled', () => {
docBase.options.location = {
locale: 'en-GB'
};
const isDisbled = PDFJS.disableRange;
sandbox.stub(Browser, 'isIOS').returns(false);
sandbox.stub(PDFJS, 'getDocument').returns(Promise.resolve({}));

PDFJS.disableRange = false;

return docBase.initViewer('').then(() => {
expect(PDFJS.getDocument).to.be.calledWith({
url: '',
rangeChunkSize: 524288,
httpHeaders: {
[X_BOX_ACCEPT_ENCODING_HEADER]: X_BOX_ACCEPT_ENCODING_IDENTITY
}
});

// Reset to original value
PDFJS.disableRange = isDisbled;
});
});

it('should resolve the loading task and set the document/viewer', () => {
const doc = {
url: 'url'
Expand Down

0 comments on commit 8ebf984

Please sign in to comment.