curlget空格_如何在Linux上的curlGET请求URL中编码空格?curl get空格
The problem is like this: I would like to send a GET request using curl and the content has spaces, such as
问题是这样的:我想使⽤curl发送GET请求,并且内容中有空格,例如
curl "example/send?msg=hello world"
The and the “world” will be left away if this is executed directory on .
如果在上执⾏此则和“世界”将被保留。
How to encode spaces in curl request URL?
如何在curl请求URL中编码空格?
You can use the --date-urlencode option of :
您可以使⽤的--date-urlencode选项:
--data-urlencode <data>
(HTTP) This posts data, similar to the other --data options with
the exception that this performs URL-encoding. (Added in 7.18.0)
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.
Just be careful so that the content doesn't contain any = or
@ symbols, as that will then make the syntax match one of the
other cases below!
=content
This will make curl URL-encode the content and pass that on.
The preceding = symbol is not included in the data.
name=content
This will make curl URL-encode the content part and pass that
on. Note that the name part is expected to be URL-encoded
already.
@filename
This will make curl load data from the given file (including
any newlines), URL-encode that data and pass it on in the POST.
name@filename
This will make curl load data from the given file (including any
newlines), URL-encode that data and pass it on in the POST. The
name part gets an equal sign appended, resulting in
name=urlencoded-file-content. Note that the name is expected to
be URL-encoded already.
You command could be:
您的命令可能是:
curl -G "example/send" --data-urlencode "msg=hello world"
url编码处理Here, -G is to tell curl that the data are used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a ‘?’ separator.
在这⾥, -G告诉curl在HTTP GET请求中使⽤数据,⽽不是在其他情况下使⽤的POST请求。 数据将以'?'附加到URL。 分隔器。
Answered by Eric Z Ma.
埃⾥克·马(Eric Z Ma)回答。
curl get空格

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。