Skip to content

Instantly share code, notes, and snippets.



Created Jul 12, 2021
What would you like to do?
function kurl() {
# URLをパース
read proto server path <<<$(echo ${1//// })
DOC=/${path// //}
[[ x"${HOST}" == x"${PORT}" ]] && PORT=80
# /dev/tcp/~をfd3で開く
exec 3<>/dev/tcp/${HOST}/$PORT
# HTTPリクエストを送る
echo -en "GET ${DOC} HTTP/1.0\r\nHost: ${HOST}\r\n\r\n" >&3
# レスポンスを読み取る
(while read line; do
[[ "$line" == $'\r' ]] && break
done && cat) <&3
# #3 fdをクローズする
exec 3>&-

This comment has been minimized.

Copy link
Owner Author

@lirlia lirlia commented Jul 12, 2021

This script is download file from HTTP.

You can use this command like kurl http://mysite:8000/
This script isn't adopt HTTPS.

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