我有一个带有以下签名的mvc web api: public HttpResponseMessage Frob(string thing, [FromBody]string body)
。我已经能够获得一个非空值的唯一方法是发送带有前导=
符号的数据。所以当我运行curl "$server/Frob" -d '=somedata'
时,效果很好。如何通过curl发送数据到mvc4 web服务
问题出现在我想运行curl "$server/Frob" -d '=some+data'
时。 +
变成一个空间。没问题我说,我只会curl "$server/Frob" --data-urlencode '=some+data'
。不,卷曲文档说
To be CGI-compliant, the <data> part should begin with a name followed by a
separator and a content specification. The <data> part can be passed to curl
using one of the following syntaxes:
[...]
=content
This will make curl URL-encode the content and pass that on.
The preceding = symbol is not included in the data.
[...]
我可以掏出通过Perl或任何对内容进行编码,然后前面加上=
和发送,但我们有了一个更好的办法!我是否需要对mvc web api进行更改,或者是否存在卷曲伏都教使=
停留?