feat(download): add --header flag for custom HTTP headers #155
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/pget!155
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/custom-headers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Add
--headerflag for custom HTTP headers. Supports multiple flags andPGET_HEADERenv var.Why
Users need to set authentication tokens, cookies, or other custom headers for protected downloads.
Implementation
flag.Func("header", ...)accumulates multiple valuesPGET_HEADERenv var supports semicolon-separated pairs for single-value env compatibilityNewClient, stored asmap[string]string, applied inNewRequestafter User-AgentKey: Value— split on first colon, trimmedTesting
--header "Authorization: Bearer token"sets the header--headerflags accumulate correctlyPGET_HEADER="X-A:1;X-B:2"works via envgo build ./...,go vet ./...,golangci-lint run— all cleanBreaking Changes
None
Closes #93, #91, #92
Review: APPROVED
Verification
go vet ./...— ✅ passesgo build ./...— ✅ passesgolangci-lint v2 run ./...— ✅ 0 issuesChanges
internal/config/config.go—Headers []string,--headerflag viaflag.Func,PGET_HEADERenv var (semicolon-separated)internal/downloader/client.go— Parsed intomap[string]stringinNewClient, applied inNewRequestafter User-AgentBehavior
--headerflags accumulate:--header "X-A: 1" --header "X-B: 2"PGET_HEADER="X-A:1;X-B:2"(semicolons in values not supported)Key: Value, split on first colon, trimmedCloses #91, #92, #93 on merge.