Find out the HTTP header status using the Mac OS X Terminal

HTTP header output

Today an article on a somewhat "technical" topic that is certainly not of interest to everyone: As part of my "real" work, I occasionally have to read out the HTTP header that websites send for certain requests. For example, you can find out whether a 404 error page from a website really sends a 404 status code or whether it only reports an error but actually sends a 200 OK status code.

HTTP header output
This is what the output of the HTTP header including the status code looks like in the terminal.

So far I have always used online services for this, which can be found on the net under the term “web sniffer” or something similar. But you can also do it very easily with OS X's on-board resources by doing this Port uses.

For example, if I want to query which headers the domain www.sir-apfelot.de reports, then I enter this command in the terminal:

curl --HEAD https://www.sir-apfelot.de

That works very well for me, but there are sometimes problems when the server doesn't understand the HEAD command and then doesn't send any headers to curl. In this case, you can also use the Verbose command "-v" to display the complete output when the page is called up. Things that interest us appear at the top. But don't be surprised, you get the complete source code of the page in the terminal, which can be a lot of letter salad here and there. :)

The correct command for this “complete output” is:

curl -v https://www.sir-apfelot.de

My tips & tricks about technology & Apple

Did you like the article and did the instructions on the blog help you? Then I would be happy if you the blog via a Steady Membership would support.

1 comment on “Finding HTTP Header Status with Mac OS X Terminal”

  1. CURL is a great thing indeed! In principle, use the online services such as https://websniffer.cc/ also nothing else than CURL in the background/backend. Alternatively, browser plugins are also very useful, or go directly to “Network” in Developer Tools (F12). Command line is of course also possible, but mmn not so comfortable ;)

Post a comment

Your e-mail address will not be published. Required fields are marked with * marked

In the Sir Apfelot Blog you will find advice, instructions and reviews on Apple products such as the iPhone, iPad, Apple Watch, AirPods, iMac, Mac Pro, Mac Mini and Mac Studio.

Specials
Shopping
  •  
  •