1

When using netcat in linux, I can do a get fine from the command line.

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.

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

4

2 回答 2

2

我能够通过使用wireshark进行故障排除来使其正常工作。

我需要添加一个 Content-Type

这有效


POST /test.php HTTP/1.1
Host:127.0.0.1
Content-Type:application/x-www-form-urlencoded
Content-Length:9

txt=99999



-----

PHP

于 2011-04-15T01:44:00.827 回答
1

您是否需要出于特定原因使用 netcat?Curl 可以原生发帖:http: //linux.byexamples.com/archives/311/sending-http-post-using-curl-command/

于 2011-02-08T02:40:39.163 回答