Skip to content

Instantly share code, notes, and snippets.

@mattstabeler
Last active August 26, 2021 12:42
Show Gist options
  • Save mattstabeler/b430697a55c665c9137edfdfb41f634b to your computer and use it in GitHub Desktop.
Save mattstabeler/b430697a55c665c9137edfdfb41f634b to your computer and use it in GitHub Desktop.
A simple alias for pulling out headers for HTTP requests
#!/bin/bash
if [ -z $1 ];
then echo "Missing url, try $0 http://example.com";
else
curl -v -s $1 1> /dev/null
fi
## based on https://lornajane.net/posts/2014/view-only-headers-with-curl
@mattstabeler
Copy link
Author

put it in somewhere like ~/bin/curl_headers then make it executable chmod +x ~/bin/curl_headers

then use it like

curl_headers https://google.com
*   Trying 142.250.200.14...
* TCP_NODELAY set
* Connected to google.com (142.250.200.14) port 80 (#0)
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 26 Aug 2021 12:40:54 GMT
< Expires: Sat, 25 Sep 2021 12:40:54 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< 
{ [219 bytes data]
* Connection #0 to host google.com left intact
* Closing connection 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment