Menu
Coddy logo textTech

Response Headers

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

After the status line the server sends headers: facts about the response, one per line, in the form Name: value.

The ones you will read constantly:

  • Content-Type: what the body is. text/html, application/json. Clients use this to decide how to read it.
  • Content-Length: how many bytes the body is.
  • Location: on a 3xx, where to go instead.

curl -I asks for the headers only, using the HEAD method, so you can inspect a response without downloading a large body.

curl -sI http://127.0.0.1:9113/index.html

Header names are case insensitive, so a server may send Content-Type or content-type and both are correct. Search for them with grep -i or you will miss matches.

challenge icon

Challenge

Medium

Inspect a response without downloading it.

Serve a folder containing index.html on port 9113, then fetch the headers only and print just the content type line. Expected output:

Content-type: text/html

Match it case insensitively and anchor to the start of the line: grep -i "^content-type". Do not print the whole header block, since it also contains a date that changes every second.

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