From 08737375f8b43996b6aea14021bea3bd7c45ae14 Mon Sep 17 00:00:00 2001 From: "terje.kristiansen" Date: Wed, 15 Jan 2014 09:57:17 +0100 Subject: [PATCH] Added withCredentials parameter and passing it to xhr requests --- src/core/chunked_stream.js | 3 ++- src/core/network.js | 2 ++ src/core/pdf_manager.js | 1 + src/core/worker.js | 3 ++- src/display/api.js | 3 +++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index bc61dc580..040151815 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -242,7 +242,8 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() { }; this.networkManager = new NetworkManager(this.url, { getXhr: getXhr, - httpHeaders: args.httpHeaders + httpHeaders: args.httpHeaders, + withCredentials: args.withCredentials }); this.sendRequest = function ChunkedStreamManager_sendRequest(begin, end) { this.networkManager.requestRange(begin, end, { diff --git a/src/core/network.js b/src/core/network.js index cccb21c00..e96f2f6f8 100644 --- a/src/core/network.js +++ b/src/core/network.js @@ -44,6 +44,7 @@ var NetworkManager = (function NetworkManagerClosure() { this.url = url; args = args || {}; this.httpHeaders = args.httpHeaders || {}; + this.withCredentials = args.withCredentials || false; this.getXhr = args.getXhr || function NetworkManager_getXhr() { //#if B2G @@ -96,6 +97,7 @@ var NetworkManager = (function NetworkManagerClosure() { }; xhr.open('GET', this.url); + xhr.withCredentials = this.withCredentials; for (var property in this.httpHeaders) { var value = this.httpHeaders[property]; if (typeof value === 'undefined') { diff --git a/src/core/pdf_manager.js b/src/core/pdf_manager.js index 257a4c11d..de7b59447 100644 --- a/src/core/pdf_manager.js +++ b/src/core/pdf_manager.js @@ -142,6 +142,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() { var params = { msgHandler: msgHandler, httpHeaders: args.httpHeaders, + withCredentials: args.withCredentials, chunkedViewerLoading: args.chunkedViewerLoading, disableAutoFetch: args.disableAutoFetch, initialData: args.initialData diff --git a/src/core/worker.js b/src/core/worker.js index 3be1cb026..f52cd0ef6 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -94,7 +94,8 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { } var networkManager = new NetworkManager(source.url, { - httpHeaders: source.httpHeaders + httpHeaders: source.httpHeaders, + withCredentials: source.withCredentials }); var fullRequestXhrId = networkManager.requestFull({ onHeadersReceived: function onHeadersReceived() { diff --git a/src/display/api.js b/src/display/api.js index 5c3e16198..d234e8509 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -117,6 +117,9 @@ PDFJS.verbosity = PDFJS.verbosity === undefined ? * - url - The URL of the PDF. * - data - A typed array with PDF data. * - httpHeaders - Basic authentication headers. + * - withCredentials - Indicates whether or not cross-site Access-Control + * requests should be made using credentials such as + * cookies or authorization headers. The default is false. * - password - For decrypting password-protected PDFs. * - initialData - A typed array with the first portion or all of the pdf data. * Used by the extension since some data is already loaded