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

Allow sending empty HTTP header #3536

Open
jcamiel opened this issue Dec 18, 2024 · 2 comments
Open

Allow sending empty HTTP header #3536

jcamiel opened this issue Dec 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Dec 18, 2024

With this Hurl file:

GET https://foo.com
x-foo: 
HTTP 200

We're providing the header x-foo: to libcurl. User headers like this are filtered by libcurl, they're not sent as empty headers.
This syntax is also used by libcurl to remove the HTTP request headers that are automatically added (like Host, Accept etc...).

Example: this file

GET https://foo.com
Host:
HTTP 200

will remove the Host header used by curl.

We may need to provide a way to send a user empty request header. From https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html, this is achieved by adding a header with a semi colon: x-foo;.

We could support a special syntax to indicate that we want to send an empty header

GET https://foo.com
x-foo: ""
HTTP 200

or

GET https://foo.com
x-foo: -
HTTP 200

Or, for this case, we use the incoming --header option:

GET https://foo.com
[Options]
header: x-foo;
HTTP 200

In this case, we need to make some change in the client.rs code responsible for configuring libcurl headers.

@jcamiel jcamiel added the enhancement New feature or request label Dec 18, 2024
@fabricereix
Copy link
Collaborator

I would rather choose consistency within Hurl (standard key:value) than consistency with curl.
to be discussed...

@jcamiel
Copy link
Collaborator Author

jcamiel commented Dec 19, 2024

We can change the current code so that a header name: will add an empty header (they're filtered by libcurl today). Maybe having a specific option to remove headers added by libcurl (we re just speaking about Accept and Host here) isn't worth it, given that you can override them or set it with an empty value if we change the code.

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

No branches or pull requests

2 participants