GitHub GitHub GitHub GitHub

Go package httpreader implements io.ReaderAt, io.Reader, and io.Seeker depending on HTTP Range Requests.

Package httpreader is the most efficient. Unlike others, it makes HTTP Requests only when needed. Httpreader reuses http.Response.Body if the reading is sequential. Httpreader makes a HTTP Request when the reading offset is changed Non-sequential such as calling Seeker method to skip large data.

There is no need to buffer the httpreader because the underlying layer of httpreader is http.Response.Body. The number of HTTP Requests only depends on the degree of sequential reading.

It can be used for example with “archive/zip” package in Go standard library. Together they can be used to access remote (HTTP accessible) ZIP archives without needing to download the whole archive file.

HTTP Range Requests (see RFC 7233) are used to retrieve the requested byte range.


The following example outputs a file list of a remote zip archive without downloading the whole archive:

package main

import (

func main() {
	u, _ := url.Parse("")
	r, err := httpreader.NewReader(u)
	if err != nil {
		fmt.Printf("%v\n", err)
	defer r.Close()
	zipReader, err := zip.NewReader(r, r.Length)
	if err != nil {
		fmt.Printf("%v\n", err)
	for _, f := range zipReader.File {




View Github