I want to add an empty header in my HTTP packet. Something like:
Someheader:
But I see that libcurl does not support that. They propose a workaround by concatenating the empty header with another header:
"Someheader:\r\nheader1: value"
Does the latest libcurl offer another — more proper — way to send an empty header?
An empty header is valid according to the HTTP specs, so ASP.NET Core shouldn't remove it. Anyway, there's an easy workaround to prevent empty headers from being removed: instead of setting the header to an empty string, set it to a string containing only whitespace: Response.
To send an HTTP header with a Curl request, you can use the -H command-line option and pass the header name and value in "Key: Value" format. If you do not provide a value for the header, this will remove the standard header that Curl would otherwise send.
To pass multiple headers in a curl request you simply add additional -H or --header to your curl command. For standard HTTP header fields such as User-Agent, Cookie, Host, there is actually another way to setting them.
Per an example on the libcurl site, you can replace the colon with a semicolon. That will expand into an empty header. So:
Someheader;
will actually be sent as:
Someheader:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With