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>
5 files changed
tree: c1e711dfa6ef0e345c0495e067a222440fee2b18
  1. firstboot/
  2. http-redirect/
  3. LICENSE
  4. meson.build
  5. meson_options.txt
  6. README.md
README.md

phosphor-misc

phosphor-misc is a collection of miscellaneous OpenBMC functions that doesn't really fit anywhere else.

Contributing

If you have a new function in mind to be hosted in phosphor-misc, it is usually a good idea to mention it on the OpenBMC mailing list before writing any code. There might already be an implementation of the desired function or the community may suggest alternatives.

phosphor-misc patches are reviewed using the Gerrit instance at https://gerrit.openbmc-project.xyz.

Please submit patches to Gerrit. More information on using Gerrit can be found here. https://github.com/openbmc/phosphor-misc is a hosting mirror only and GitHub pull requests are not monitored and will not be accepted.

Patch checklist. Please ensure patches adhere to the following guidelines:

For questions or help please come join us on the mailing list or in IRC.