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

HTTP header output

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

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 the thing very easily with the on-board tools of OS X by using the terminal.

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 sometimes there are problems when the server doesn't understand the HEAD command and then doesn't send any headers to curl. In this case, the complete output can also be output when the page is called up with the verbose command "-v". The things that interest us then appear at the top. But don't be surprised, you get the complete source code of the page displayed in the terminal, which can be a lot of letters here and there. :)

The correct command for this "complete edition" is:

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

 

Effectively for free: iPhone 13 Mini and iPhone 13 deals with top conditions at Otelo - Advertisement

1 comment

  1. Karen says:

    CURL is a great thing indeed! In principle, use the online services such as https://websniffer.cc/ nothing more 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 also possible, of course, but mMn not so comfortable;)

Leave a Comment

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