Httpie: 可以发送原始帖子有效载荷

创建于 2015-05-14  ·  7评论  ·  资料来源: httpie/httpie

...没有逃脱和另一种魔法

真假的啊?

--raw-payload类的选项下

question

最有用的评论

是的,任何通过STDIN传入的数据都将作为请求正文发送,例如:

$ echo 'raw payload' | http httpbin.org/post

https://github.com/jakubroztocil/httpie#redirected -input

所有7条评论

是的,任何通过STDIN传入的数据都将作为请求正文发送,例如:

$ echo 'raw payload' | http httpbin.org/post

https://github.com/jakubroztocil/httpie#redirected -input

谢谢你,雅库布!

除了--ignore-stdin我在http --help内看不到任何提及,这可能对帮助文本有很好的补充吗? (此外,这方面的工作真棒!)

您也可以使用http httpbin.org/post <<< 'raw payload'

但,

$ echo 'running' | http -v put localhost:5000/state

正在发送Content-Type: application/json标头。

PUT /state HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 8
Content-Type: application/json
Host: localhost:5000
User-Agent: HTTPie/0.9.9

running

并且在接收端的正确实现当然是尝试将其解析为JSON,并且失败了。

@furkanmustafa application/jsonhttpie使用的默认内容类型。

如果您在请求中明确声明内容类型,则将解决该问题:

$ echo 'running' |http httpbin.org/post Content-Type:text/plain

甚至发送压缩内容:

$ echo 'running' |gzip |http httpbin.org/post Content-Type:text/plain Content-Encoding:gzip

您也可以使用http httpbin.org/post <<< 'raw payload'

似乎无法使用Powershell, 'rawBody' | http post :8080/api/events为我工作

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

rshurts picture rshurts  ·  5评论

loretoparisi picture loretoparisi  ·  6评论

filipesperandio picture filipesperandio  ·  3评论

ghost picture ghost  ·  5评论

tonsV2 picture tonsV2  ·  4评论