feat(download): add --header flag for custom HTTP headers #155

Merged
fuzzy merged 2 commits from feature/custom-headers into main 2026-07-14 06:08:33 +00:00
Owner

What

Add --header flag for custom HTTP headers. Supports multiple flags and PGET_HEADER env var.

Why

Users need to set authentication tokens, cookies, or other custom headers for protected downloads.

Implementation

  • flag.Func("header", ...) accumulates multiple values
  • PGET_HEADER env var supports semicolon-separated pairs for single-value env compatibility
  • Headers parsed in NewClient, stored as map[string]string, applied in NewRequest after User-Agent
  • Format: Key: Value — split on first colon, trimmed

Testing

  • Manual: --header "Authorization: Bearer token" sets the header
  • Manual: multiple --header flags accumulate correctly
  • Manual: PGET_HEADER="X-A:1;X-B:2" works via env
  • go build ./..., go vet ./..., golangci-lint run — all clean

Breaking Changes

None

Closes #93, #91, #92

## What Add `--header` flag for custom HTTP headers. Supports multiple flags and `PGET_HEADER` env var. ## Why Users need to set authentication tokens, cookies, or other custom headers for protected downloads. ## Implementation - `flag.Func("header", ...)` accumulates multiple values - `PGET_HEADER` env var supports semicolon-separated pairs for single-value env compatibility - Headers parsed in `NewClient`, stored as `map[string]string`, applied in `NewRequest` after User-Agent - Format: `Key: Value` — split on first colon, trimmed ## Testing - [x] Manual: `--header "Authorization: Bearer token"` sets the header - [x] Manual: multiple `--header` flags accumulate correctly - [x] Manual: `PGET_HEADER="X-A:1;X-B:2"` works via env - [x] `go build ./...`, `go vet ./...`, `golangci-lint run` — all clean ## Breaking Changes None Closes #93, #91, #92
flag.Func accumulates multiple --header values. PGET_HEADER env var
accepts semicolon-separated pairs. Headers applied on every request.

Closes #93, #91, #92
docs(roadmap): mark custom headers complete
All checks were successful
Test and Release / test (pull_request) Successful in 6m2s
Test and Release / lint (pull_request) Successful in 6m51s
409a66bf01
Closes #93, #91, #92
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-14 06:02:24 +00:00
the.auditor left a comment

Review: APPROVED

Verification

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

Changes

  • internal/config/config.goHeaders []string, --header flag via flag.Func, PGET_HEADER env var (semicolon-separated)
  • internal/downloader/client.go — Parsed into map[string]string in NewClient, applied in NewRequest after User-Agent
  • ROADMAP.md — Marks Phase 4 custom header items as [x]

Behavior

  • Multiple --header flags accumulate: --header "X-A: 1" --header "X-B: 2"
  • Env var: PGET_HEADER="X-A:1;X-B:2" (semicolons in values not supported)
  • Format: Key: Value, split on first colon, trimmed
  • Custom headers overwrite User-Agent if same key (applied after)

Closes #91, #92, #93 on merge.

## Review: APPROVED ### Verification - `go vet ./...` — ✅ passes - `go build ./...` — ✅ passes - `golangci-lint v2 run ./...` — ✅ 0 issues ### Changes - `internal/config/config.go` — `Headers []string`, `--header` flag via `flag.Func`, `PGET_HEADER` env var (semicolon-separated) - `internal/downloader/client.go` — Parsed into `map[string]string` in `NewClient`, applied in `NewRequest` after User-Agent - ROADMAP.md — Marks Phase 4 custom header items as [x] ### Behavior - Multiple `--header` flags accumulate: `--header "X-A: 1" --header "X-B: 2"` - Env var: `PGET_HEADER="X-A:1;X-B:2"` (semicolons in values not supported) - Format: `Key: Value`, split on first colon, trimmed - Custom headers overwrite User-Agent if same key (applied after) Closes #91, #92, #93 on merge.
fuzzy merged commit 409a66bf01 into main 2026-07-14 06:08:33 +00:00
fuzzy deleted branch feature/custom-headers 2026-07-14 06:08:33 +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!155
No description provided.