使用curl发布数据时打印响应内容主体
我在 ubuntu 上使用以下命令:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"foo":"bar"}' http://localhost:8888/
以下是收到的响应:
< HTTP/1.1 200 OK
< Content-Length: 3
< Content-Type: text/html; charset=UTF-8
< Server: TornadoServer/2.1
<
* Connection #0 to host localhost left intact
* Closing connection #0
所以我的问题是;如何使用curl 发布并打印响应内容正文?
I'm using the command below on ubuntu:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"foo":"bar"}' http://localhost:8888/
The following is the response received:
< HTTP/1.1 200 OK
< Content-Length: 3
< Content-Type: text/html; charset=UTF-8
< Server: TornadoServer/2.1
<
* Connection #0 to host localhost left intact
* Closing connection #0
So my question is; how do I post using curl and print out the response content body?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它终于对我有用了这个命令:
It finally worked for me with this command:
您是否尝试将
-d '{"foo":"bar"}'
替换为-d 'foo=bar'
?只要请求成功,您就不需要执行任何特殊操作来接收响应内容正文。Did you try to replace
-d '{"foo":"bar"}'
with-d 'foo=bar'
? You shouldn't have to do anything special to receive the response content body as long as the request succeeds.