Browse Source

Merge pull request #4124 from tkristiansen/with-credentials

Allow setting xhr.withCredentials
Yury Delendik 11 years ago
parent
commit
ab4f27b272
  1. 3
      src/core/chunked_stream.js
  2. 2
      src/core/network.js
  3. 1
      src/core/pdf_manager.js
  4. 3
      src/core/worker.js
  5. 3
      src/display/api.js

3
src/core/chunked_stream.js

@ -242,7 +242,8 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() { @@ -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, {

2
src/core/network.js

@ -44,6 +44,7 @@ var NetworkManager = (function NetworkManagerClosure() { @@ -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() { @@ -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') {

1
src/core/pdf_manager.js

@ -142,6 +142,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() { @@ -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

3
src/core/worker.js

@ -94,7 +94,8 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { @@ -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() {

3
src/display/api.js

@ -117,6 +117,9 @@ PDFJS.verbosity = PDFJS.verbosity === undefined ? @@ -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

Loading…
Cancel
Save