feat(http): implement HTTP range request logic #130

Merged
fuzzy merged 2 commits from feat/http-range-requests into main 2026-07-13 17:58:50 +00:00
Owner

What

Implement HTTP range request logic: HEAD probe, Accept-Ranges detection, Content-Length parsing, chunk splitting, and Range header generation.

Refactor Client struct to store User-Agent internally (removes need to pass config to NewRequest).

Why

Core prerequisite for parallel chunked downloads — determines if server supports ranges, calculates chunk boundaries, and builds correct Range headers.

Testing

  • go vet ./... passes
  • go build ./... passes
  • golangci-lint run ./... passes
  • Pre-commit hooks pass

Breaking Changes

Client.NewRequest signature changed — removed cfg parameter (User-Agent now stored in Client struct).

Notes

  • ProbeURL — HEAD request, parses Content-Length and Accept-Ranges: bytes
  • SplitChunks — divides file into [start, end) byte ranges for N workers
  • BuildRangeHeader — formats HTTP Range header value (e.g. bytes=0-1023)
  • FileInfo — size + ranges boolean
  • Chunk — start/end byte offsets

Closes #0027
Closes #0028
Closes #0029
Closes #0030
Closes #0031

## What Implement HTTP range request logic: HEAD probe, Accept-Ranges detection, Content-Length parsing, chunk splitting, and Range header generation. Refactor Client struct to store User-Agent internally (removes need to pass config to NewRequest). ## Why Core prerequisite for parallel chunked downloads — determines if server supports ranges, calculates chunk boundaries, and builds correct Range headers. ## Testing - [x] `go vet ./...` passes - [x] `go build ./...` passes - [x] `golangci-lint run ./...` passes - [x] Pre-commit hooks pass ## Breaking Changes `Client.NewRequest` signature changed — removed `cfg` parameter (User-Agent now stored in Client struct). ## Notes - `ProbeURL` — HEAD request, parses `Content-Length` and `Accept-Ranges: bytes` - `SplitChunks` — divides file into `[start, end)` byte ranges for N workers - `BuildRangeHeader` — formats HTTP `Range` header value (e.g. `bytes=0-1023`) - `FileInfo` — size + ranges boolean - `Chunk` — start/end byte offsets Closes #0027 Closes #0028 Closes #0029 Closes #0030 Closes #0031
Closes #0027 Closes #0028 Closes #0029 Closes #0030 Closes #0031
docs(roadmap): mark HTTP range requests complete
All checks were successful
Test and Release / test (pull_request) Successful in 1m28s
Test and Release / lint (pull_request) Successful in 9m18s
1db79fde7b
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-13 17:49:41 +00:00
the.auditor left a comment

Review: APPROVED

Verification

  • go vet ./... passes
  • go build ./... passes
  • golangci-lint v2 run ./... 0 issues

Changes

  • internal/downloader/range.go (new) — ProbeURL, SplitChunks, BuildRangeHeader, FileInfo, Chunk
  • internal/downloader/client.go — stores userAgent on Client, NewRequest no longer needs cfg (fixes #128)
  • ROADMAP.md — Marks Phase 2 range request items as [x]

Suggestions (non-blocking)

  • #131SplitChunks(0, n) produces invalid Range header for zero-size files
  • #132 — Missing tests for range logic

Closes #0027, #0028, #0029, #0030, #0031 on merge.

## Review: APPROVED ### Verification - `go vet ./...` — ✅ passes - `go build ./...` — ✅ passes - `golangci-lint v2 run ./...` — ✅ 0 issues ### Changes - `internal/downloader/range.go` (new) — ProbeURL, SplitChunks, BuildRangeHeader, FileInfo, Chunk - `internal/downloader/client.go` — stores userAgent on Client, NewRequest no longer needs cfg (fixes #128) - `ROADMAP.md` — Marks Phase 2 range request items as [x] ### Suggestions (non-blocking) - #131 — `SplitChunks(0, n)` produces invalid Range header for zero-size files - #132 — Missing tests for range logic Closes #0027, #0028, #0029, #0030, #0031 on merge.
fuzzy merged commit 1db79fde7b into main 2026-07-13 17:58:50 +00:00
fuzzy deleted branch feat/http-range-requests 2026-07-13 17:58:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/pget!130
No description provided.