Post 带卷曲的数据,没有 Content-Type header
Post data with curl with no Content-Type header
如果我这样做
curl -v --data "hello" example.com
curl 发送
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
我知道我可以通过 -X 'Content-Type: something/else
来更改 Content-Type header 的值,但是有没有办法在不设置 header 的情况下发送数据完全没有?
要告诉 curl 根本不发送 header,请使用 -H
传递没有值的 header,如下所示(引号不是绝对必要的):
curl --data hello -H 'Content-Type:' example.com
这将发送此请求:
POST / HTTP/1.1
Host: example.com
User-Agent: curl/7.77.0
Accept: */*
Content-Length: 5
hello
来自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:
".
如果我这样做
curl -v --data "hello" example.com
curl 发送
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
我知道我可以通过 -X 'Content-Type: something/else
来更改 Content-Type header 的值,但是有没有办法在不设置 header 的情况下发送数据完全没有?
要告诉 curl 根本不发送 header,请使用 -H
传递没有值的 header,如下所示(引号不是绝对必要的):
curl --data hello -H 'Content-Type:' example.com
这将发送此请求:
POST / HTTP/1.1
Host: example.com
User-Agent: curl/7.77.0
Accept: */*
Content-Length: 5
hello
来自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:
".