Menu
Coddy logo textTech

Recap: curl Flags

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

The working set, worth committing to memory:

-s              silent: no progress meter
-i / -I         headers with the body / headers only
-o FILE         save the body (-o /dev/null to discard)
-H 'K: V'       add a request header
-X METHOD       change the method
-w '%{...}'     print facts about the transfer
--max-time N    give up after N seconds
--fail          exit non-zero on 4xx and 5xx

Two habits go with them. Always -s, because the progress meter goes to the error stream and ruins output. And keep status code and exit code apart: the first is the server's answer, the second is whether the conversation happened at all.

When something is unclear, put a listener in the way and read the request back. Guessing what was sent is always slower than looking.

challenge icon

Challenge

Hard

Put four flags together in one command.

  1. Create index.html containing done and serve the folder on port 9121
  2. Fetch it silently, discarding the body, giving up after 5 seconds, and print the status code followed by a space and the byte count

The text is 4 characters plus a newline, so the output is:

200 5

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