code style fixes

This commit is contained in:
beat 2012-05-08 14:17:51 +02:00
parent 7786e4fefb
commit e11cad884c
2 changed files with 11 additions and 7 deletions

View File

@ -10,7 +10,7 @@
* @param {string|TypedAray} source Either a url to a PDF is located or a * @param {string|TypedAray} source Either a url to a PDF is located or a
* typed array (Uint8Array) already populated with data. * typed array (Uint8Array) already populated with data.
* @param {Object} headers An object containing the http headers like this: * @param {Object} headers An object containing the http headers like this:
* { Authorization: "BASIC XXX" } * { Authorization: "BASIC XXX" }.
* @return {Promise} A promise that is resolved with {PDFDocumentProxy} object. * @return {Promise} A promise that is resolved with {PDFDocumentProxy} object.
*/ */
PDFJS.getDocument = function getDocument(source, headers) { PDFJS.getDocument = function getDocument(source, headers) {
@ -32,7 +32,7 @@ PDFJS.getDocument = function getDocument(source, headers) {
promise.reject('Unexpected server response of ' + promise.reject('Unexpected server response of ' +
e.target.status + '.'); e.target.status + '.');
}, },
headers: headers headers: headers
}, },
function getPDFLoad(data) { function getPDFLoad(data) {
transport.sendData(data); transport.sendData(data);

View File

@ -33,13 +33,17 @@ function getPdf(arg, callback) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', params.url); xhr.open('GET', params.url);
if(params.headers){
for(var property in params.headers){ var headers = params.headers;
if(typeof(params.headers[property]) !== undefined){ if (headers) {
xhr.setRequestHeader(property, params.headers[property]); for (var property in headers) {
} if (typeof headers[property] === 'undefined')
continue;
xhr.setRequestHeader(property, params.headers[property]);
} }
} }
xhr.mozResponseType = xhr.responseType = 'arraybuffer'; xhr.mozResponseType = xhr.responseType = 'arraybuffer';
var protocol = params.url.indexOf(':') < 0 ? window.location.protocol : var protocol = params.url.indexOf(':') < 0 ? window.location.protocol :
params.url.substring(0, params.url.indexOf(':') + 1); params.url.substring(0, params.url.indexOf(':') + 1);