logoalt Hacker News

tredre3 • yesterday at 9:26 PM • 2 replies • view on HN

HTTP supports negative ranges, so you can request the final 64KB and scan it. If you don't find the Central Directory (unlikely unless the zip contains 10k files and/or lots of comments) then you just request another 64KB.


Replies

sltkr • yesterday at 9:59 PM

Note that the end-of-central-directory record at the end of the file contains the size and offset of the central directory, so if the central directory is not in the final 64 KiB you already have, you know exactly which range you need to request to get it (i.e. you don't need to keep scanning backwards 64 KiB at a time).