Menu
Coddy logo textTech

POST with -d

Lesson 32 of 47 in Coddy's Networking with the Terminal course.

So far every request has asked for something. -d sends something instead:

curl -s -d 'name=ada' http://127.0.0.1:9122/signup

Two things happen the moment you add it. curl switches the method from GET to POST without being asked, and it attaches what you gave it as the request body.

So -d is not just "add data", it changes the kind of request. If you want a POST with no body at all you have to say -X POST yourself.

Where GET puts its parameters in the URL for everyone to see and log, POST puts them in the body. That is why forms with passwords use POST: not because the body is encrypted, it is not, but because URLs end up in browser history, server logs and referrer headers.

challenge icon

Challenge

Expert

Send your first POST and read back what the server received.

  1. Start the capture listener on port 9122 (it replies 200 and writes the request into req.txt)
  2. POST name=ada to http://127.0.0.1:9122/signup
  3. Print the first line of req.txt

Expected output:

POST /signup HTTP/1.1

Give curl --max-time 3 so it does not wait forever, and discard its output.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground