Netcat HTTP posting
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-Ty开发者_JAVA百科pe:text/html
Content-Length:10
text=hello
The header shows it was successful but nothing gets returned ? Please help
I was able to get it working by troubleshooting with 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
-----
PHP
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/
精彩评论