Skip to content

Conversation

Copy link

Copilot AI commented Nov 14, 2025

Adds ability to specify custom HTTP headers via CLI flag or environment variable, enabling authenticated downloads and other header-based use cases.

Changes

  • CLI flag: Added -H/--header flag accepting "Key: Value" format (repeatable)
  • Environment variable: PGET_HEADERS as JSON map (e.g., {"Authorization":"Bearer token"})
  • Config: New HeadersToMap() function parses CLI headers and merges with env vars
  • Client: Modified PGetHTTPClient.Do() to apply custom headers while preserving User-Agent
  • Tests: Added validation for header parsing and transmission

Usage

# CLI flags
pget -H "Authorization: Bearer token123" https://api.example.com/file.tar ./dest

# Environment variable
PGET_HEADERS='{"Authorization":"Bearer token123"}' pget https://api.example.com/file.tar ./dest

# Combine both (CLI takes precedence for duplicate keys)
PGET_HEADERS='{"X-Env":"value"}' pget -H "X-CLI: value" https://example.com/file.tar ./dest

Headers are applied to all HTTP requests. User-Agent is always set to pget version and cannot be overridden.

Original prompt

This section details on the original issue you should resolve

<issue_title>Allow providing http header</issue_title>
<issue_description>It would be nice to have an option to specify http headers. Maybe limit to http headers that won't conflict with pget.

For example: This would enable authentication with Authorization header</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add option to provide HTTP headers Add HTTP header support for authenticated downloads Nov 14, 2025
Copilot finished work on behalf of markphelps November 14, 2025 20:34
Copilot AI requested a review from markphelps November 14, 2025 20:34
@markphelps markphelps marked this pull request as ready for review November 15, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow providing http header

2 participants