mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Ignore falsy header values and improve ajaxHeaders documentation
This commit is contained in:
parent
15fe35a589
commit
6fdf81f266
@ -2189,7 +2189,10 @@ function OpenSeadragon( options ){
|
||||
|
||||
if (headers) {
|
||||
Object.keys(headers).forEach(function (headerName) {
|
||||
request.setRequestHeader(headerName, headers[headerName]);
|
||||
// Falsy header values will be ignored
|
||||
if (headers[headerName]) {
|
||||
request.setRequestHeader(headerName, headers[headerName]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@
|
||||
* Defaults to the setting in {@link OpenSeadragon.Options}.
|
||||
* @param {Object} [options.ajaxHeaders={}]
|
||||
* A set of headers to include when making tile AJAX requests.
|
||||
* Note that these headers will be merged over any headers specified in {@link OpenSeadragon.Options}.
|
||||
*/
|
||||
$.TiledImage = function( options ) {
|
||||
var _this = this;
|
||||
|
@ -582,6 +582,9 @@ $.TileSource.prototype = {
|
||||
* Responsible for retrieving the headers which will be attached to the image request for the
|
||||
* region specified by the given x, y, and level components.
|
||||
* This option is only relevant if {@link OpenSeadragon.Options}.loadTilesWithAjax is set to true.
|
||||
* The headers returned here will override headers specified at the Viewer or TiledImage level.
|
||||
* Specifying a falsy value for a header will clear its existing value set at the Viewer or
|
||||
* TiledImage level (if any).
|
||||
* @function
|
||||
* @param {Number} level
|
||||
* @param {Number} x
|
||||
|
@ -1239,6 +1239,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
* @param {Object} [options.ajaxHeaders]
|
||||
* A set of headers to include when making tile AJAX requests.
|
||||
* Note that these headers will be merged over any headers specified in {@link OpenSeadragon.Options}.
|
||||
* Specifying a falsy value for a header will clear its existing value set at the Viewer level (if any).
|
||||
* requests.
|
||||
* @param {Function} [options.success] A function that gets called when the image is
|
||||
* successfully added. It's passed the event object which contains a single property:
|
||||
|
@ -58,14 +58,14 @@
|
||||
ajaxHeaders: {
|
||||
// Example of using the viewer-level ajaxHeaders option
|
||||
// for providing an authentication token.
|
||||
'Authentication': 'Bearer MY_AUTH_TOKEN'
|
||||
"Authentication": "Bearer MY_AUTH_TOKEN"
|
||||
}
|
||||
});
|
||||
|
||||
viewer.addTiledImage({
|
||||
// The headers specified here will be combined with those in the Viewer object (if any)
|
||||
ajaxHeaders: {
|
||||
"X-My-TileSource-Header": "Something"
|
||||
"X-My-TiledImage-Header": "Something"
|
||||
},
|
||||
tileSource: myCustomTileSource
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user