Last active
July 5, 2016 17:05
-
-
Save andresvia/da0b1505b8e883a1fa5ebf65171ddcc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this is only suited for text files | |
set -eu | |
url="$1" | |
scheme="${url/:\/\/*}" | |
if [ "$scheme" != "https" ] | |
then | |
echo oops... only https:// is supported | |
exit 1 | |
fi | |
no_scheme="${url#$scheme://}" | |
host_port="${no_scheme/\/*/}" | |
host=${host_port/:*} | |
port=${host_port#$host} | |
path="${no_scheme#$host_port}" | |
connect_to="${host}${port:-:443}" | |
get="${path:-/}" | |
openssl s_client -quiet -connect "${connect_to}" << EOF | tr -d '\r' | sed '1,/^$/d' | |
GET ${get} HTTP/1.1 | |
Host: ${host_port} | |
User-Agent: opensslget | |
Connection: close | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment