fix(downloader): SplitChunks produces invalid Range header for zero-size file #131

Closed
opened 2026-07-13 17:50:24 +00:00 by the.auditor · 1 comment
Owner

internal/downloader/range.go:64-65SplitChunks(0, n) returns [{Start: 0, End: 0}], producing BuildRangeHeader output bytes=0--1 which is an invalid HTTP Range header.

For zero-size files, SplitChunks should return an empty slice — no chunks needed for an empty file. The caller should check FileInfo.Size == 0 before initiating chunked download.

if fileSize <= 0 {
    return nil
}

Discovered during review of PR #130.

`internal/downloader/range.go:64-65` — `SplitChunks(0, n)` returns `[{Start: 0, End: 0}]`, producing `BuildRangeHeader` output `bytes=0--1` which is an invalid HTTP Range header. For zero-size files, `SplitChunks` should return an empty slice — no chunks needed for an empty file. The caller should check `FileInfo.Size == 0` before initiating chunked download. ```go if fileSize <= 0 { return nil } ``` Discovered during review of PR #130.
Owner

Closing — implemented in PR #165. SplitChunks returns nil for fileSize <= 0, Download() handles empty chunks as zero-size file (no-op).

Closing — implemented in PR #[165](https://git.lan.thwap.org/thwap/pget/pulls/165). SplitChunks returns nil for fileSize <= 0, Download() handles empty chunks as zero-size file (no-op).
Sign in to join this conversation.
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#131
No description provided.