$ show saulpw/unzip-http
unzip-http is a Python-based command-line tool and library for extracting specific files from a ZIP archive hosted over HTTP without downloading the entire archive. It achieves this by leveraging HTTP range requests to download only the necessary portions of the ZIP file, such as the central directory and the compressed data of individual files. The tool can list the contents of a remote ZIP or extract one or more files (with support for wildcards) to the local filesystem or to stdout. The architecture centers around the `RemoteZipFile` class, which handles the HTTP communication and ZIP file parsing, and the `ZipStream` class, which provides on-the-fly decompression of deflate-compressed data. The CLI entry point in `unzip_http.py` provides a user-friendly interface for common operations, while the same code can be imported and used as a library in other Python programs. The project relies solely on the `urllib3` library for HTTP operations. Two components stand out for their reusability and technical merit: the `ZipStream` class, which implements a streaming decompressor for deflate data that can be used in any context requiring incremental decompression, and the `ZipInfo.parse_extra` method, which robustly handles ZIP64 extra fields to support large files. The project is actively maintained, with recent updates supporting modern Python versions and improving robustness (e.g., better handling of missing Accept-Ranges headers).
The LLM identified 2 files worth highlighting for reuse:
The ZipStream class implements a raw I/O stream that decompresses deflate-compressed data on the fly using zlib, allowing for efficient streaming extraction of compressed files without loading the entire compressed data into memory. It can be reused in any context requiring incremental decompression of deflate data streams.
The ZipInfo.parse_extra method handles ZIP64 extra fields in ZIP file headers, parsing variable-length fields to update compressed size, uncompressed size, and header offset when they exceed the 32-bit limits of the standard ZIP format. This method is self-contained and can be extracted for use in any ZIP file parsing implementation.