Added withCredentials parameter and passing it to xhr requests
This commit is contained in:
		
							parent
							
								
									4d01ff4079
								
							
						
					
					
						commit
						08737375f8
					
				@ -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, {
 | 
			
		||||
 | 
			
		||||
@ -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') {
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user