Linux Netcat HTTP 发布
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4929041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Netcat HTTP posting
提问by user607473
When using netcat in linux, I can do a get fine from the command line.
在 linux 中使用 netcat 时,我可以从命令行中得到很好的结果。
nc google.com 80
GET / HTTP/1.1
Host:google.com
Can someone please show me how to do a post. I tried with no luck. I also tried different combos with \r\n or just a new line. I can get it working in perl and c.
有人可以告诉我如何发帖。我试过没有运气。我还尝试了不同的组合与 \r\n 或只是一个新行。我可以让它在 perl 和 c 中工作。
nc google.com 80
POST /test.php HTTP/1.1
Host:whatever.com
Content-Type:text/html
Content-Length:10
text=hello
The header shows it was successful but nothing gets returned ? Please help
标题显示它成功但没有返回任何内容?请帮忙
回答by dicato
Do you need to use netcat for a specific reason? Curl can send posts natively: http://linux.byexamples.com/archives/311/sending-http-post-using-curl-command/
您是否需要出于特定原因使用 netcat?Curl 可以本地发送帖子:http: //linux.byexamples.com/archives/311/sending-http-post-using-curl-command/
回答by user607473
I was able to get it working by troubleshooting with wireshark.
通过使用wireshark进行故障排除,我能够使其正常工作。
I need to add a Content-Type
我需要添加一个内容类型
This works
这有效
POST /test.php HTTP/1.1
Host:127.0.0.1
Content-Type:application/x-www-form-urlencoded
Content-Length:9
txt=99999
POST /test.php HTTP/1.1
Host:127.0.0.1
Content-Type:application/x-www-form-urlencoded
Content-Length:9
txt=99999
-----
-----
PHP
PHP