👁19views
curl Command: Get HTTP Response Headers in Terminal

CloudScale AI SEO - Article Summary
  • 1.
    What it is
    This article explains how to use the curl command in Mac or Linux terminals to retrieve HTTP/HTTPS response headers from any URL.
  • 2.
    Why it matters
    Getting response headers is essential for web developers to debug issues, check server configurations, and verify that their applications are sending correct HTTP information without needing browser plugins.
  • 3.
    Key takeaway
    Use curl in the terminal to quickly check HTTP headers instead of relying on browser extensions.

Web devs need to know the http headers their apps/webpages. This can be easily achieved using a browser plugin for Chrome or Firefox. But I prefer to use the command terminal, and curl makes this really easy.

curl -I andrewbaker.ninja
HTTP/1.1 302 Found
Date: Thu, 17 Nov 2022 14:01:53 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: https://andrewbaker.ninja/
Connection: close
Content-Type: text/html; charset=iso-8859-1

## Alternative
url --head https://andrewbaker.ninja
HTTP/1.1 200 OK
Date: Thu, 17 Nov 2022 14:08:36 GMT
Server: Apache
X-Powered-By: PHP/7.3.18
Link: ; rel="https://api.w.org/", ; rel="alternate"; type="application/json", ; rel=shortlink
X-Frame-Options: SAMEORIGIN
Cache-Control: max-age=0, no-cache
Connection: close
Content-Type: text/html; charset=UTF-8