Seeing the Headers
Lesson 26 of 47 in Coddy's Networking with the Terminal course.
By default curl prints the body and nothing else. Two flags change that.
-i includes the response headers above the body, which is what you want when a page looks right but something is off.
-I fetches the headers only, using the HEAD method, so nothing large is downloaded. Reach for it when you want to check whether something exists, what type it is, or how big it is.
curl -si http://127.0.0.1:9116/index.html | head -1
curl -sI http://127.0.0.1:9116/index.htmlBe careful comparing raw header output between runs: it usually contains a Date, which changes every second. Filter for the header you actually mean rather than diffing the whole block.
Challenge
MediumFetch a response and read its first line, headers included.
Serve a folder containing index.html on port 9116, then ask curl to include the headers and print only the first line, which is the status line:
HTTP/1.0 200 OKTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
6curl in Depth
Seeing the HeadersSaving ResponsesCustom HeadersStatus and Timingcurl Exit CodesRecap: curl FlagsPractice on your own: Terminal playground