Last active
September 22, 2022 13:25
-
-
Save felegy/763db2729288df41beb0a1e298b9fc53 to your computer and use it in GitHub Desktop.
Poor man's `CURL` or `WGET`
This file contains 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
#!/usr/bin/env sh | |
# | |
# Usage: http-get.sh [PATH PORT HOST] | |
# | |
# Environment variables | |
# REQUEST_PATH - path of the request, default value `/` | |
# REQUEST_PORT - http port, default value `80` | |
# REQUEST_HOST - host of the request, default value `localhost` | |
REQUEST_PATH=${1:-${REQUEST_PATH-/}} | |
REQUEST_PORT=${2:-${REQUEST_PORT-80}} | |
REQUEST_HOST=${3:-${REQUEST_HOST-localhost}} | |
exec 5<> /dev/tcp/$REQUEST_HOST/$REQUEST_PORT | |
cat <&5 & | |
printf "GET $REQUEST_PATH HTTP/1.0\r\n\r\n" >&5 | |
cat <&5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment