Menu
Coddy logo textTech

What -d Actually Sends

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

The request line told you the method. Now look at the body, which is the last thing in the request, after the blank line.

Whatever you passed to -d is sent literally. -d 'name=ada' puts exactly name=ada on the wire. Several -d flags are joined with &, so -d 'a=1' -d 'b=2' sends a=1&b=2.

curl also adds a Content-Length header counting those bytes, because the server needs to know where the body ends. You do not have to compute it, which is one of the quiet conveniences of using a client instead of nc.

Reading the body back off the wire is the fastest way to settle any argument about what a client is really sending.

challenge icon

Challenge

Expert

Read your own body back off the wire.

  1. Start the capture listener on port 9123
  2. POST the two fields name=ada and role=eng, as two separate -d flags
  3. Print the last line of req.txt, which is the body

Expected output:

name=ada&role=eng

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