From ca2c8b4a50590326bda47d8883e9ef57dbae09b8 Mon Sep 17 00:00:00 2001 From: Dominika Date: Fri, 24 Jul 2020 14:50:08 +0200 Subject: [PATCH] Added basic proxying; Importing to gitlab. --- src/response/proxy.sh | 4 ++++ src/server.sh | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100755 src/response/proxy.sh diff --git a/src/response/proxy.sh b/src/response/proxy.sh new file mode 100755 index 0000000..764237b --- /dev/null +++ b/src/response/proxy.sh @@ -0,0 +1,4 @@ +printf "HTTP/1.0 200 OK +${cfg[extra_headers]}\r\n\r\n" + +curl ${cfg[proxy_url]}${r[url]} \ No newline at end of file diff --git a/src/server.sh b/src/server.sh index 8ff521d..6ba14cc 100755 --- a/src/server.sh +++ b/src/server.sh @@ -126,6 +126,10 @@ if [[ ${cfg[auth_required]} == true && ${r[authorized]} != true ]]; then r[status]=401 fi +if [[ ${cfg[proxy]} == true ]]; then + r[status]=211 +fi + if [[ ${r[post]} == true && ${r[status]} == 200 ]]; then # This whole ordeal is here to prevent passing binary data as a variable. @@ -170,6 +174,8 @@ fi if [[ ${r[status]} == 210 && ${cfg[autoindex]} == true ]]; then source "src/response/listing.sh" +elif [[ ${r[status]} == 211 ]]; then + source "src/response/proxy.sh" elif [[ ${r[status]} == 200 ]]; then source "src/response/200.sh" elif [[ ${r[status]} == 401 ]]; then