Skip to the main text

Archives

Open a ZIP without downloading it

You can, and it costs kilobytes rather than the whole archive. A ZIP keeps its index — the list of everything inside — at the very end of the file. If the server allows range requests, you fetch just that last chunk and read the full file list without touching the contents. Foretaste does it in one click and shows you the byte count.

course-materials.zip
0.17% of the file was read
read 67 KB of 40,013,838 bytes
10 entries listed. The other 39,946,838 bytes stayed on the server.

01

Why this is possible at all

A ZIP is not one compressed blob. It is a run of individually compressed files, each with a small header in front of it, and then — after all of them — a central directory: one record per file giving its name, its compressed and uncompressed size, and the byte offset where its data starts. The last thing in the file is a short end of central directory record saying how big that directory is and where it begins.

The index is at the end because ZIP was designed for archives written across several floppy disks, where the writer could not know the final offsets until it had finished. Forty years later, that decision is what lets you read the contents list of a 40 MB archive over a network without transferring 40 MB.

HTTP supplies the other half. A server that answers with Accept-Ranges: bytes will honour a Range header and return just the slice you asked for, with status 206 Partial Content. So: fetch the last few kilobytes, find the end-of-directory record, learn where the directory starts, fetch that, and you have every file name and size in the archive.

Extracting one file works the same way. The directory already told you where that file's bytes are and how many there are, so it is one more ranged request for exactly that span, and one call to the decompressor.

02

Doing it in one click

  1. Allow Foretaste on the site holding the archive.

    One click, one site. Foretaste asks for no site access when you install it.

  2. Right-click the link and choose "Open with Foretaste".

    Or click the marker beside the link. The listing appears as a folder tree, sorted folders first, with sizes rolled up from what is inside them.

  3. Open or save one file from inside the archive.

    Only that file is fetched, and it opens in the ordinary viewer — a PDF as a PDF, a CSV as a grid. Saving one file out of the archive is free and always available.

03

How much data it actually reads

These figures were measured against a local server that logs every request, with the reader counting the bytes it received. They are not estimates, and Foretaste reports the real number on screen each time rather than repeating these.

Measured over HTTP with real range requests.
Archive What was asked for Bytes fetched
40,013,838 bytes List all 10 entries about 67 KB — 0.17%
40,013,838 bytes Open one small file from inside 97 bytes
13,111 bytes List 8 entries the whole file

The third row is the honest one. Below roughly a hundred kilobytes, picking at an archive in two or three ranged requests costs more round trips than simply taking it, so Foretaste takes it — and says so on screen rather than printing a saving it did not make. An earlier version claimed a saving on every archive and was wrong about the small ones.

04

When it does not work

The server will not do ranges

Some servers send no Accept-Ranges header, and some advertise ranges and then ignore the header and return the entire file with status 200. Generated downloads and streamed responses often behave this way. Foretaste falls back to downloading the archive and tells you that is what happened — you still get the listing, it just cost the whole file.

The server refuses the request

A site protected by a WAF, or one that checks that requests came from its own pages, will answer 403. Foretaste says so plainly and points you at saving the file instead, which goes through the browser's own download machinery and usually gets through. A 401 means sign in to the site in another tab and try again.

You have not allowed Foretaste on that site

Reading another website's file from a script normally requires that website to opt in with CORS headers, which is why you cannot do this from an ordinary web page. An extension can, but only for sites you have explicitly granted it — so Foretaste asks first, one site at a time. Until you do, it offers to save the file, which needs no such permission.

The archive is encrypted or damaged

A password-protected ZIP prompts you once, and the password stays in that tab — it is never stored or sent. A wrong one says so. If the index itself is corrupt there is nothing at the end of the file to read, and Foretaste reports the failure rather than showing a half-list.

05

Doing it yourself, without an extension

Nothing here is proprietary. With curl and unzip you can do the same thing by hand:

# 1. Does the server support ranges, and how big is the file?
curl -sI https://example.com/big.zip | grep -i 'accept-ranges\|content-length'

# 2. Fetch the last 64 KB. The index lives at the end.
curl -s -r -65535 https://example.com/big.zip -o tail.zip

# 3. List it. unzip warns about the missing beginning, then
#    adjusts the offsets and prints the contents anyway.
unzip -l tail.zip

If step three cannot find the index, the archive's directory is larger than the chunk you took — fetch a bigger tail and try again. Extracting a single file by hand means reading the offset and size out of the directory and issuing a third ranged request for exactly that span, which is the point at which a tool starts to be worth having.

On the desktop, 7-Zip and unzip will list a local archive without extracting it, but both want the whole file on disk first. The remote-listing trick is the part that needs range requests.

06

What about RAR, 7z and TAR?

None of them can be read this way, and it is not a gap in Foretaste. A .tar.gz is a single gzip stream: there is no index anywhere, and you cannot decompress the end without decompressing everything before it. 7z and RAR do keep a directory, but it is neither always at a predictable end nor readable without the surrounding structure, so Foretaste reads those archives whole.

So the ranged trick is ZIP only — and, incidentally, formats that are secretly ZIPs: .docx, .xlsx, .pptx and .epub all use the same container. The full format list says which archives Foretaste reads whole and which it picks at.