💾 Archived View for 1436.ninja › Phlog › 20190824.post captured on 2020-10-31 at 01:11:09.
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
# Cleaned up HTTPS->HTTP proxy code ### entered in vim on RPoJ ### 20190824 Courtesy of Javier on comp.misc (plus a bit I added for /.):
$ cat doit.cgi
server="rpoa"
ths="http:\/\/$server\/cgi-bin\/doit.cgi\?"
req=$(urlencode -d "$1")
req2="$ths$(urlencode "$req")"
dom=$ths"https:\/\/"$( printf "$1" | awk -F[/:] '{print $4}' )
if [ "$req"=="https://slashdot.org/" ]; then
printf "%s\n\n" "Content-Type: text/html"
fi
curl -sS -I "$req" | \
printf "%s\n\n" "$(grep "^Content-Type:" | sed 's@text/plain@text/html@')"
curl -sS "$req" | \
sed "/href=\"[[:alnum:]]/ s@href=\"@href=\"$req2@g; \
/href=\"\// s@href=\"@href=\"https://$dom@g; \
/src=\"[[:alnum:]]/ s@src=\"@src=\"$req2@g; \
/src=\"\// s@src=\"@src=\"$dom@g; \
s@"$req2"http@http@g; \
s@https://http://@http://@g"