Curl only show header

cURL is a command-line tool that gives you a lot of useful information. cURL is used to check errors, download and view content, and many more things. By default, cURL does not show the content headers it only shows HTML content, etc. In this guide we will see how to only show headers using curl.

Simple CURL

For example if you do curl https://cyberpanel.net, curl will download the content of the page:

Curl only show header

You can use the --head flag to display only headers and not all other information.

For example, if you only want to see headers for https://solveddoc.com, you can run the following command:

curl --head https://solveddoc.com

Your output will look something like this

[root@CentOS-78-64-minimal ~]# curl --head  https://solveddoc.com
HTTP/1.1 301 Moved Per`Preformatted text`manently
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
content-type: text/html; charset=UTF-8
x-litespeed-tag: 5e6_HTTP.200,5e6_HTTP.301
x-redirect-by: WordPress
location: https://www.solveddoc.com/
x-litespeed-cache-control: no-cache
date: Wed, 13 Apr 2022 08:11:14 GMT
server: LiteSpeed
alt-svc: h3=":443"; ma=2592000, h3-29=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="43,46"

There are a lot of other flags you can use with curl like -s, -D etc;

  • -s use to hide the progress bar
  • -D - Use to dump headers to stdout indicated by

Curl with detailed logs (-v or -verbose)

If you want to see extra information you can use -v or verbose.

This is something that wii give you extra information with the output.

Example:

Lets check the output of curl -v www.solveddoc.com

[root@Cyberpanel ~]# curl -v  https://solveddoc.com
* About to connect() to solveddoc.com port 443 (#0)
*   Trying 168.119.15.231...
* Connected to solveddoc.com (168.119.15.231) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
*       subject: CN=solveddoc.com
*       start date: Feb 25 22:14:01 2022 GMT
*       expire date: May 26 22:14:00 2022 GMT
*       common name: solveddoc.com
*       issuer: CN=R3,O=Let's Encrypt,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: solveddoc.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Connection: Keep-Alive
< Keep-Alive: timeout=5, max=100
< content-type: text/html; charset=UTF-8
< x-redirect-by: WordPress
< location: https://www.solveddoc.com/
< x-litespeed-cache: miss
< content-length: 0
< date: Wed, 13 Apr 2022 08:03:01 GMT
< server: LiteSpeed
< alt-svc: h3=":443"; ma=2592000, h3-29=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="43,46"
<

In this example we can see three types of indications <, >, and ‘*’. So, what do they mean?

  • > indicate request headers.
  • < indicate response headers.
  • * indicate additional information.