hurl icon indicating copy to clipboard operation
hurl copied to clipboard

Is there a way to define headers once and reuse them?

Open kidbrax opened this issue 2 years ago • 2 comments

Problem to solve

I'd like to define a set of headers and have them used for every request instead of adding them to each request. Can multiple headers be defined as a single variable? Or is there another method to do so?

Proposal

If it's not already available, it would be good to have any way to define headers once. Either at the top of a file or as a cli switch.

Additional context and resources

n/a

Tasks to complete

  • [ ] ...

kidbrax avatar Sep 08 '23 21:09 kidbrax

Hi,

Currently no but we could implement --header option from curl:

$ hurl --header a:b test.hurl

Will add a header a to every request of test.hurl. We could also use it for a particular request in [Options] section to use template:

GET https://...
[Options]
header: {{header_api_key}}: MYKEY

See #1710

jcamiel avatar Sep 09 '23 07:09 jcamiel

That would work. It would also be nice to be able to just define it once in the file and have it apply to all requests

kidbrax avatar Sep 09 '23 15:09 kidbrax