Is it safe to remove Content-Type and Expect headers from HTTP POST request with empty body? #22894
Replies: 2 comments
|
The headers are a symptom of the body size being unknown rather than something to strip. So set the size explicitly: curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);That sends The one thing worth avoiding is removing |
|
@kebl3541
The documentation explicitly states that the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi!
Sometimes I need to send HTTP POST request to the server without any body content. To do this, I just set
curl_easy_setopt(curl, CURLOPT_POST, 1L);But curl automatically adds following headers:
Since I don't need to send any body, I don't need provide any Content-Type because there is no content to send.
If we don't have content, we also don't need Expect: 100-continue because we have no data to continue with.
Is it safe to set Content-Type and Expect headers values to empty string to make curl remove this headers?
Won't this break curl's internal algorithms?
When I remove Content-Type and Expect headers, curl adds Transfer-Encoding: chunked header and send one empty chunk (last chunk).
Is it safe also remove Transfer-Encoding header to make request without any body-specific information?
Thanks in advance.
All reactions