如何隐藏CLI CURL的请求输出中的标头 [英] How can I suppress the headers from CLI CURL's output of request
本文介绍了如何隐藏CLI CURL的请求输出中的标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
关于如何防止在对PHP版本进行请求时如何防止curl显示标题信息的信息很多,但对于CLI版本似乎没有任何信息。
There's plenty of info on how to prevent curl from showing header information when doing a request for the PHP version, but seemingly nothing for the CLI version.
我的请求格式为
curl -i -X POST -H 'Content-Type: application/json; charset=UTF-8' -H 'X-Accept: application/json' -H '-d '{"somedata":"12ihiuhihihed994f63dbef6b012b"}' https://myurl.com/v3/oauth/request
这行得通,但返回以下内容:
Which works, but returns this:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json
Date: Wed, 27 Mar 2013 20:42:11 GMT
P3P: policyref="/w3c/p3p.xml", CP="ALL CURa ADMa DEVa OUR IND UNI COM NAV INT STA PRE"
Server: Apache/2.2.23 (Amazon)
Status: 200 OK
X-Powered-By: PHP/5.3.20
Content-Length: 54
Connection: keep-alive
{"code":"jkhjhhjhaa","state":null}
我真正想要的是:
{"code":"jkhjhhjhaa","state":null}
推荐答案
只需从 -i
开关> curl 命令。
Simply remove the -i
switch from your curl
command.
man curl
表示:
-i,--include
(HTTP)在输出中包括HTTP标头。 HTTP标头包括服务器名称,文档日期,HTTP版本等内容。
-i, --include
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...
这篇关于如何隐藏CLI CURL的请求输出中的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文