History log of /openbmc/phosphor-misc/http-redirect/http-redirect.awk (Results 1 – 1 of 1)
Revision Date Author Comments
# 4ee8f2c5 09-Jan-2020 Milton Miller <miltonm@us.ibm.com>

http-redirect: Minimal awk script to redirect http to https

A simple script written in awk to parse HTTP/1.1 requests and then
generate a reply to use the https:// URL.

Only support GET and HEAD me

http-redirect: Minimal awk script to redirect http to https

A simple script written in awk to parse HTTP/1.1 requests and then
generate a reply to use the https:// URL.

Only support GET and HEAD methods; others will get Not Implemented.

Recognises multi-line headers, repeated headers, and absolute URI
(where the host is in the URI and the Host: header is ignored).
Supports host headers that include a port for non-standard redirect.
Decodes %xx url encoding before path lookup.

Includes systemd socket and service files. Includes unit tests.

Includes trace subroutine that writes trace to a file if tracefile
variable set (either awk -v or additional awk -f segment).

Includes add-url.awk that adds url {request, destination} pairs
read from a file agumenting the valid URI array.

Prior version testing:
Tested on withspoon with awk script in /home/root/redirect.awk
* ran Unit tests script
* systemd units installed in /run/systemd/system/
* curl -w %{redirect_url}'\n' http://hostname.example/

Tests:
test cases in ./tests show location is parsed.
with mawk 1.3.3
nc -l -p 8080 < fifo | awk -f redirect.awk -Wi > fifo
firefox http://localhost:8080
with gawk 4.0.1
nc -l -p 8080 -c "awk -f http-redirect.awk" &
curl -v -k -L http://localhost:8080/
curl -v -I -k -L http://localhost:8080/

Change-Id: Ic361247dedfd7bcff620d793dd7082c247c9e78e
Signed-off-by: Milton Miller <miltonm@us.ibm.com>

show more ...