Skip to content

httpreader: random access over an HTTP resource - #1953

Open
hdonnay wants to merge 5 commits into
quay:mainfrom
hdonnay:hack/httpreader
Open

httpreader: random access over an HTTP resource#1953
hdonnay wants to merge 5 commits into
quay:mainfrom
hdonnay:hack/httpreader

Conversation

@hdonnay

@hdonnay hdonnay commented Jul 17, 2026

Copy link
Copy Markdown
Member

This adds a package (internal/httpreader) that implements io.ReaderAt over HTTP requests. It incorporates a lot of tricks I know from a past life dealing with RFC7233 non- and selectively- compliant servers.

Then, the fetcher package gains the capability to use an httpreader.Reader when it notices that a layer is uncompressed.

Future work may involve the tarfs layer doing transparent caching and being able to handle compressed layers directly.

@hdonnay
hdonnay requested review from a team as code owners July 17, 2026 18:41
@hdonnay
hdonnay requested a review from crozzy July 17, 2026 18:41
@hdonnay

hdonnay commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Conflicts with #1948

@hdonnay
hdonnay force-pushed the hack/httpreader branch 6 times, most recently from 9c3ce05 to 719faf9 Compare July 22, 2026 16:41
@hdonnay
hdonnay force-pushed the hack/httpreader branch 2 times, most recently from 7635a0a to 01c8352 Compare July 27, 2026 20:06
@BradLugo
BradLugo self-requested a review July 27, 2026 20:12

@BradLugo BradLugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's enough to address for now. I'll do another deep dive in the next review

Comment thread internal/httpreader/reader.go
Comment thread internal/httpreader/content_range.rl
Comment thread internal/httpreader/reader.go Outdated
Comment thread internal/httpreader/metrics.go
Comment thread internal/httpreader/ragel.sh
Comment thread internal/httpreader/reader.go Outdated
Comment thread pkg/tarfs/testdata/paxsize.tar
Comment thread pkg/tarfs/tarfs_test.go
}

//go:generate sh testdata/create_paxsize.sh
func TestPAXSize(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this test fails without 5d4f550. Again, not really a blocker for me, mostly fyi.

Comment thread pkg/tarfs/parse.go
Comment on lines +155 to +164
for s.Scan() {
fs := strings.FieldsFunc(s.Text(), func(r rune) bool { return r == ' ' || r == '=' })
if fs[1] == "size" {
// This is *not* the stringified octal madness of a real header.
*p, err = strconv.ParseInt(fs[2], 10, 64)
if err != nil {
return nil, parseErr("bad block at %d: weird PAX header: bad size: %v", off, err)
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never really looked at the pax spec before, but after briefly reading about it, it seems like we'd at least need to break after finding size so we don't hit one of the extended headers, which might cause a an error: https://pubs.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_03

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean. This is handling the extended headers.

Comment thread libindex/fetcher.go Outdated
hdonnay added 4 commits July 28, 2026 13:37
This package does an io.ReaderAt over an HTTP resource. It includes a
novel way to determine the end of a resource for partially-compliant
servers. Using wholly-compliant servers is recommended.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I08d6671217535ac897a2ed5c9cd20aa06a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I162632409abf01efcec4633713c9f0d06a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I8bd87cb66de93dad080c1d6d8aac34a96a6a6964
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I6c2d6cfae9f6e742056c157e38b8b6156a6a6964
@hdonnay
hdonnay requested a review from BradLugo July 28, 2026 18:44
This handles the "easy" case of simply proxying reads for uncompressed
tar archives to range requests.

Future improvements would move the "spooling" out of this package and
into the `fs.FS` implementation.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: I9d200dd841954054df0b187b9fd160a56a6a6964
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants