Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add curl -H/--header option to add a request header one each request #2144

Closed
jcamiel opened this issue Nov 10, 2023 · 5 comments · Fixed by #3419
Closed

Add curl -H/--header option to add a request header one each request #2144

jcamiel opened this issue Nov 10, 2023 · 5 comments · Fixed by #3419
Assignees
Labels
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Nov 10, 2023

Add support for curl -H/--header option to add a request header on each request:

$ hurl --header "foo: bar" test.hurl

Adding multiple header is possible:

$ hurl --header "foo: bar" --header "bar: baz" test.hurl

To define: while redundant with header, per request header option should be also possible ?

GET https://foo.com
[Options]
header: "foo: bar"
HTTP 200
@jcamiel jcamiel added the enhancement New feature or request label Nov 10, 2023
@jcamiel jcamiel added this to the 5.0.0 milestone Apr 17, 2024
@jcamiel jcamiel modified the milestones: 5.0.0, 5.1.0 Aug 28, 2024
@jcamiel
Copy link
Collaborator Author

jcamiel commented Nov 14, 2024

@theoforger if you're interesting by this issue, you're good to go!

This option is a curl option and it makes sense to be exposed by Hurl.

For a start, we could implement in a first PR this option:

$ hurl --header "foo: bar" test.hurl

Multiple headers could be added

$ hurl --header "foo: bar" --header "baz:bar" test.hurl

That will a a request header foo:bar to every request of a Hurl file.

It will make also sense to implement it on [Options]section (in another PRs of course):

GET https://foo.com
[Options]
header: toto:tutu
HTTP 200

This can be redundant with our header syntax

GET https://foo.com
toto: tutu
HTTP 200

But in the future we plan to implement [Options] section at the start of a Hurl file that will be apply to every entry of a file. For instance:

[Options]
insecure: true
header: token:xxx

GET https://foo.com

GET https://bar.com

GET https://baz.com

Will add a header on every request of the Hurl file

@theoforger
Copy link
Contributor

@jcamiel Sounds good! I'll take this one 😆

@theoforger
Copy link
Contributor

@jcamiel I noticed that the curl option also supports input through a file:

curl -H @filename https://example.com

or through stdin:

curl -H @- https://example.com

Do we want to implement them as well?

@jcamiel
Copy link
Collaborator Author

jcamiel commented Nov 16, 2024

For the moment, it doesn't seem necessary. We can implement it later if someone has a strong need of it!

@theoforger
Copy link
Contributor

@jcamiel Hello again! I just submitted a PR for this. Any feedback is appreciated 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants