-
Notifications
You must be signed in to change notification settings - Fork 191
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
416 Error for Fetching Outside Range #193
Comments
I've got a branch here that gets the max byte allowed (i.e file size): https://github.com/geotiffjs/geotiff.js/compare/master...ilan-gold:ilan-gold/fix_outofrange_issue?expand=1 |
As an update @constantinius the node API also returns a 416 here, but it doesn't error out for some reason. Specifically if you run the code above, you will see a request for byte range |
Thanks for reporting this issue! There seems to be something amiss here. When I get the headers of the fileI get the following response:
The byte range you said was requested ( When the requested byte range at least intersects with the file size, the server shall respond with the intersection, which your server does correctly:
So, I think there is a bug elsewhere. Maybe too many blocks are requested, which are not actually required? Do you have a stack trace of the issue? Regarding your fix: I'm not too fond of the solution to be honest. The reason is that we actually get the actual file size with every range request we send (what you actually parse, I think). So ideally, we parse it from the response and set it in the source, to never request outside of the bounds of the file. I'll investigate a bit myself to see what is going on. |
There was indeed a bug when parsing an IFD. Because I only get the address of the IFD from the previous one (and not its size) I have to assume the byte size of the IFD. In this particular image, this assumed IFD size was actually larger than the IFD in question, resulting in one correct block fetch and one that happened to be completely out of the files bounds. With b9aad79 I introduced a mechanism where the total file size is stored in the Please test this and let me know if that fixes your issue. |
@constantinius I'll test it out now but that certainly looks like it does the trick (and a lot cleaner than my solution!). |
@constantinius Your fix works well, thanks so much. |
Hi @constantinius,
I'm trying to figure out if this is an issue with tiffs or a bug here. It appears that because of the way block sizes work, it is possible to make a request outside the allowed range of the file and this errors out in browsers (but not in node?). Here is an example:
I think this happens both when
offset + length > fileSize
wherefileSize
is the size of the tiff and whenfileSize < current < offset + length
wherecurrent
is from here:geotiff.js/src/source.js
Lines 132 to 143 in 8ef472f
Does this seem possible? I think it can happen because of
const firstBlockOffset = Math.floor(offset / this.blockSize) * this.blockSize;
The text was updated successfully, but these errors were encountered: