Skip to content

feat: Add --headers-file flag to read multiple headers from a file#1695

Draft
atulk-code wants to merge 1 commit intohttpie:masterfrom
atulk-code:feature/headers-file
Draft

feat: Add --headers-file flag to read multiple headers from a file#1695
atulk-code wants to merge 1 commit intohttpie:masterfrom
atulk-code:feature/headers-file

Conversation

@atulk-code
Copy link

Fixes #1595

This adds the ability to read multiple headers from a single file, similar to curl's -H @file functionality.

Features:

  • New --headers-file argument to specify a headers file
  • File format: 'Name: Value' per line
  • Empty lines and lines starting with '#' are treated as comments
  • Headers from file have lower priority than CLI-specified headers
  • Error handling for missing files and invalid formats

Example usage:
$ http --headers-file=headers.txt example.com

Where headers.txt contains:
Authorization: Bearer token123 X-Custom-Header: value # This is a comment Accept: application/json

Fixes httpie#1595

This adds the ability to read multiple headers from a single file, similar
to curl's -H @file functionality.

Features:
- New --headers-file argument to specify a headers file
- File format: 'Name: Value' per line
- Empty lines and lines starting with '#' are treated as comments
- Headers from file have lower priority than CLI-specified headers
- Error handling for missing files and invalid formats

Example usage:
  $ http --headers-file=headers.txt example.com

Where headers.txt contains:
  Authorization: Bearer token123
  X-Custom-Header: value
  # This is a comment
  Accept: application/json
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.

Possibility to read multiple headers etc, from the same file

1 participant