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 it very easily with OS X's on-board tools by doing this Port uses.

For example, if I want to query which headers the domain reports, then I enter this command in the terminal:

curl --HEAD

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

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 or at Patreon would support.

1 comment

  1. Karen says:

    CURL is a great thing indeed! In principle, use the online services such as 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.