Issue
If I do
curl -v --data "hello" example.com
curl sends
POST / HTTP/1.1
Host: example.com
User-Agent: curl/7.77.0
Accept: */*
Content-Length: 5
Content-Type: application/x-www-form-urlencoded
hello
I know that I can pass -X 'Content-Type: something/else
to change the value of the Content-Type header, but is there a way to send data without that header being set at all?
Solution
To tell curl to not send a header at all, pass the header with no value using -H
, like this (the quotes are not strictly necessary):
curl --data hello -H 'Content-Type:' example.com
this will send this request:
POST / HTTP/1.1
Host: example.com
User-Agent: curl/7.77.0
Accept: */*
Content-Length: 5
hello
From the curl man page for the -H
flag:
Remove an internal header by giving a replacement without content on the right side of the colon, as in:
-H "Host:"
. If you send the custom header with no-value then its header must be terminated with a semicolon, such as-H "X-Custom-Header;"
to send "X-Custom-Header:
".
Answered By - Boris V Answer Checked By - David Marino (WPSolving Volunteer)