Skip to content

Instantly share code, notes, and snippets.

@scentoni
Created April 7, 2023 19:23
Show Gist options
  • Save scentoni/24aca389f2bc12ece5fc005e94f2baf2 to your computer and use it in GitHub Desktop.
Save scentoni/24aca389f2bc12ece5fc005e94f2baf2 to your computer and use it in GitHub Desktop.
Abuse openssl as a curlstitute
#!/bin/bash
# Usage:
# orl 'https://eu.httpbin.org/#/HTTP_Methods'
orl () {
url=$1
rex="\([^:]*\)://\([^/]*\)\(/.*\)"
uscheme=$(echo $url |sed "s,$rex,\1,")
uauthority=$(echo $url |sed "s,$rex,\2,")
upath=$(echo $url |sed "s,$rex,\3,")
echo "GET ${upath} HTTP/1.1\r\nHost: ${uauthority}\r\nConnection: Close\r\n\r\n" | openssl s_client -quiet -state -connect ${uauthority}:443 |sed '/^HTTP/,/^\r$/d'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment