How to check HTTP Header and Connection Stats from the Command Line

A few days ago, I discussed with somebody whether a file was cached by Cloudflare or not, and this involved getting the HTTP header, and checking for CF-RAY field to see if data is going through one of Cloudflare data centers. This can be done with curl:


In the command above, -s stands for silent so that curl does not show the progress meter, -v stands for verbose to show the header, and -o /dev/null is used to discard the packet load.

You can also use -I option (fetch the HTTP-header only) with curl, which – if all you need is the HTTP header – provides a cleaner output:

I also came across httpstat Python script recently via n0where, doing much of the same thing, except it also adds transfer statistics.
It can be installed by downloading httpstat.py, or better using pip:


Let’s try it with this very blog:


The header is the same as with Curl -I, and for good reason, since httpstat relies on curl, and all curl options (except for -w, -D, -o, -s, -S) can be used with the command line. This script can be useful if you are trying to benchmark and lower TTFB (Time To First Byte), or decrease overall download times from your server.

httpstat

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
1 Comment
oldest
newest
jim st
jim st
8 years ago

From the United States (Anaheim, Ca)

me@my-system:~/work/httpstat$ httpstat http://www.cnx-software.com/

HTTP/1.1 200 OK
Date: Mon, 03 Oct 2016 23:36:10 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=db98c5339ef89a4215299d7c6436b149d1475537770; expires=Tue, 03-Oct-17 23:36:10 GMT; path=/; domain=.cnx-software.com; HttpOnly
X-Powered-By: PHP/5.5.9-1ubuntu4.19
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
X-UA-Compatible: IE=edge
Link: ; rel=”https://api.w.org/”
Server: cloudflare-nginx
CF-RAY: 2ec436fbb25b22b2-LAX

Body stored in: /tmp/tmpArRt0r

DNS Lookup TCP Connection Server Processing Content Transfer
[ 124ms | 18ms | 98ms | 49ms ]
| | | |
namelookup:124ms | | |
connect:142ms | |
starttransfer:240ms |
total:289ms

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...