falzm / burl

Pure Bash HTTP client

Home Page:http://baha.mu/burl-a-pure-bash-http-client/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

other ports and using CRLF as line terminator

DieterSpringer opened this issue · comments

Hi.
Nice little script.
I improved your script to support ports other than 80. Additionally you should use CRLF as Line-Terminator due to a security-fix in apache2.
Unfortunately i can only access github via browser i cannot send a pull request (did not work from here, seemingly) so i can only send the lines via Issue:

burl() {
shopt -s extquote

export LC_ALL=C
unset headers_read

host=${1%%/*}
path=${1#*/}

port=${host#*:}
host=${host%%:*}

[[ $path == $host ]] && path=""
[[ $port == $host ]] && port="80"

exec 3<>/dev/tcp/${host}/${port}

printf "GET /${path} HTTP/1.1\r\nHost: ${host}\r\nUser-Agent: bURL/Bash ${BASH_VERSION}\r\n\r\n" >&3

Hi, thank you for your interest in my ridiculous script :)

I've implemented support for alternative HTTP port using option -p <port>.