💾 Archived View for 1436.ninja › Phlog › 20190824.post captured on 2020-09-24 at 01:20:40.

View Raw

More Information

-=-=-=-=-=-=-

# 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

!/bin/bash

depends on curl and gridsite-clients

change this to your server

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}' )

print your mime header!

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@')"

harvest and massage your content, changing hyperlinks to this proxy

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"