1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2025-02-05 07:43:22 -08:00

print a newline between HTTP headers and response

This commit is contained in:
Connor Olding 2024-07-04 20:58:38 -07:00
parent 444227fa55
commit 41ce9f1663

View file

@ -54,7 +54,7 @@ burl() ( ### @-
f() { request | "$@" | { receive && cat ;} ;} f() { request | "$@" | { receive && cat ;} ;}
for url; do for url; do
request() { printf 'GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n' "${query#/}" "$dom" ;} request() { printf 'GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n' "${query#/}" "$dom" ;}
receive() { while IFS=$r read -r l _; [ "$l" ]; do printf >&2 %s\\n "$l"; done ;} receive() { while IFS=$r read -r l _; [ "$l" ]; do printf %s\\n "$l"; done; echo ;} >&2
proto="${url%%:*}" proto="${proto##*[!a-z0-9-]*}" proto="${url%%:*}" proto="${proto##*[!a-z0-9-]*}"
[ "$proto" ] && url="${url#$proto://}" || url="${url#//}" [ "$proto" ] && url="${url#$proto://}" || url="${url#//}"
host="${url%%/*}" query="${url#"$host"}" dom="${host%:*}" host="${url%%/*}" query="${url#"$host"}" dom="${host%:*}"