Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert curl command to netcat?

Tags:

curl

netcat

I am trying to convert a curl command (post) to a netcat command.

I already figured out how to GET/DELETE things like

curl -v http://localhost:1234/232

in netcat:

nc localhost 1234
GET 232
HOST: localhost

but I dont know how to POST something

For example: I want to save to value 2300 in my path 123

curl -v --data "val=2300" http://localhost:1234/123

and in netcat:
nc localhost 1234
POST 123
HOST: localhost

but where do i write my value?
like image 431
user3717963 Avatar asked Jan 02 '15 16:01

user3717963


1 Answers

nc localhost 1234
POST /123 HTTP/1.0
Content-Length: 8
Content-Type: application/x-www-form-urlencoded
\n
val=2300

Content-Length is set to let the server know how much data you're going to send (string length of "val=2300"). Content-Type is to let the server know in which format the data is (form-encoded). The \n is the HTTP separation character (empty line) between headers and data.

like image 150
Hans Z. Avatar answered Oct 29 '22 18:10

Hans Z.