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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
curl -svo /dev/null http://www.cnx-software.com * Rebuilt URL to: http://www.cnx-software.com/ * Trying 104.28.19.95... * Connected to www.cnx-software.com (104.28.19.95) port 80 (#0) > GET / HTTP/1.1 > Host: www.cnx-software.com > User-Agent: curl/7.47.0 > Accept: */* > < HTTP/1.1 200 OK < Date: Mon, 03 Oct 2016 09:57:17 GMT < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < Connection: keep-alive < Set-Cookie: __cfduid=d90ff49c11865e8fda1331c2977559f521475488637; expires=Tue, 03-Oct-17 09:57:17 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: <http://www.cnx-software.com/wp-json/>; rel="https://api.w.org/" < Server: cloudflare-nginx < CF-RAY: 2ebf876da273114d-SIN < { [2307 bytes data] * Connection #0 to host www.cnx-software.com left intact |
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:
|
curl -I http://www.cnx-software.com HTTP/1.1 200 OK Date: Mon, 03 Oct 2016 10:06:51 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Set-Cookie: __cfduid=d4dda8a9ec8370cf0950d26e5faf37cc21475489211; expires=Tue, 03-Oct-17 10:06:51 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 Set-Cookie: bb2_screener_=1475489211+1.1.174.2+1.1.174.2; path=/ X-UA-Compatible: IE=edge Link: <http://www.cnx-software.com/wp-json/>; rel="https://api.w.org/" Server: cloudflare-nginx CF-RAY: 2ebf9574c129081d-SIN |
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:
|
sudo pip install httpstat |
Let’s try it with this very […]