我使用curl对webapi知道返回一个特定的post请求的文件(在浏览器中运行这将触发浏览器弹出一个保存文件对话框)。我的意图是将响应字节写入文件。我使用以下命令
Im using curl against a webapi which knows to return a file for a particular post request (running this within browser would trigger the browser to pop up a "save file" dialog) . My intention is to have the response bytes written to a file. I use the following command
curl -k -i -u username:password -X POST -H "Content-Type:application/json" -d @c:\\curl\\request_body_file.json -o config.cfg 127.0.0.1:8000/myapi/trigger/export这也会导致响应头被写入输出文件,这不是我的期望。我只需要保存响应内容。
This however causes also the response header to be written to the output file, which is not my desire. I only need the response content saved.
这是输出文件的外观:
TTP/1.1 200 OK Content-Length: 12042 Content-Type: application/octet-stream; charset=UTF-8 Content-Disposition: attachment; filename=my_export Date: Wed, 23 Oct 2013 09:30:47 GMT Accept-Ranges: bytes Server: Restlet-Framework/2.1.2 X-Auth-Token: Token ODVhMzk3OWY1NjcwMjg2ZGM0MDhmNTEzYTYwZmE4M2JhNTM1YmE0Yw== xÚíÝÛãX~ØqÍÎŽçvfvervrevtrbyewd3334444 ................................curl命令如何查看以前的描述。
How would the curl command look in order to achive what I previously described.
感谢
推荐答案从curl文档:
-i,--include
-i, --include
(HTTP)在输出中包含HTTP标头。 HTTP头包括服务器名称,文档日期,HTTP版本等内容...
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...
因此删除-i参数
curl.haxx.se/docs/manpage.html
更多推荐
将响应正文保存到来自curl请求的文件
发布评论