-
-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setAjaxHeaders - headers do not get updated to the latest value #2459
Comments
Good question! That function was added with #2346. @uschmidt83 any thoughts? |
Hi @danaLumy, can you please provide a minimal reproducible example that shows the issue? Maybe it's also helpful to look at the existing header-related tests that show the expected behavior. |
Hi @uschmidt83 I have a viewer with multiple tiledImage configured like this:
In a method I call
and in the _updateAjaxHeaders the headers from the viewer ("Authorization": 'Bearer Nothing') are merged with the this._ownAjaxHeaders (("Authorization": 'Bearer Valid Token') resulting in a header with the value of the tiledImage and not the viewer. Please let me know if this is an intended behaviour. |
I agree with @danaLumy - it looks like the order of arguments in openseadragon/src/tiledimage.js Line 1059 in 5be1ab6
|
@pearcetm I think I was wrong in my first assumption that the order of the params is wrong, the viewer uses the __updateAjaxHeaders from tiledimage.js, where this._ownAjaxHeaders is never set with the new value, but if you use the setAjaxHeaders from tileImaged in viewer at line 1013 then I think it will work as expected, but I don't know the reason for using the __updateAjaxHeaders at line 1013, based on the documentation I was not able to understand why so I'll just wait to see what @uschmidt83 thinks of all this. |
It isn't necessarily a bug, because the behavior you're seeing is described in the documentation (emphasis mine):
It is a bit counterintuitive, however, that propagating changes to the |
Hi @danaLumy, it also took me a while to re-familarize myself with my own code.
Yes, it is. @pearcetm quoted the relevant part from the documentation that explains the order in which headers take precedence ( The idea is that you put your most generic headers in the In your example code, you put an If your Hi @pearcetm,
can you explain to me what use case you're thinking of and why the current implementation doesn't work for it? |
@uschmidt83 I think the current implementation is very solid and for most cases does exactly the right thing. Perhaps adding a third parameter to the function signature: I'm not saying this should be done - it may not be a good idea at all. One can make an argument that devs should update all |
Yeah, I'd say improving the documentation is the first step here. |
I think the reason I find the current API a bit confusing is the The other part of it is, I'm struggling to think of a scenario in which |
@pearcetm Good points! @uschmidt83 What are your thoughts? |
Sorry for being silent for a while. If I remember correctly, OpenSeadragon already had the concept of AJAX headers that either belong to either the viewer, a tiled image, or a tile, and the rules how to merge them. I simply wrote some code to update the headers while respecting the concept that was already in place.
It seems to me that this scenario would still be better served by just setting the headers for the viewer. I think the problem is rather documentation to tell users that headers should always be set for the viewer, unless different headers are needed for each tiled image.
I agree, that's why I also mentioned it in the documentation: Lines 1043 to 1048 in 59645e3
To be honest, I personally don't really care if the API is modified or amended. (For various reasons, I never actually got to use the code that I contributed in #2346.) But I agree that the documentation should be improved to be more explicit about common uses cases and pitfalls. |
@uschmidt83 I think that when integrating OSD we've missed this aspect, and now I'm reconsidering the way we set the headers, because we need all the time the headers set on the viewer. Thank you for taking the time to clear for me the implementation and also the order of the headers. @iangilman, @pearcetm I agree that improving the documentation would make it easier to configure the headers. Thank you, this answered my question. |
Thank you all! I've marked this as a documentation issue... It's open for anyone who wants to take a whack at improving the docs about it :) |
hey @iangilman , could you please assign this issue to me so that i can work on it. |
@hem4nn Great! Do you understand what needs documenting here? I realize the conversation has had a lot of back and forth... |
I've tried to use the setAjaxHeaders method to update the Authorization header when the token expires but the header for TiledImage and Tiles is still the expired token. I've read the implementation of the setAjaxHeaders and it seems that the merging of the headers is done incorrect in tiledimage.js line 1059 and line 1081. The way the parameters are ordered in the extend() method will result in having the old values as a result of the merging. Is this behaviour intended or is this a bug?
The text was updated successfully, but these errors were encountered: