From 4239466077f1ea3fc7f006f68ac07fae2e3b35d2 Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 15 Aug 2023 22:59:38 +0200 Subject: [PATCH] add `` `refresh` an additional fallback, as the mission for this project remains to implement pretty much every standard way of https upgrading --- redirector.go | 5 ++++- response.html | 10 ++++++++-- response.min.html | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/redirector.go b/redirector.go index 612a829..4091f1a 100644 --- a/redirector.go +++ b/redirector.go @@ -3,6 +3,7 @@ package main import ( _ "embed" "fmt" + "html" "net/http" "net/url" "strings" @@ -29,13 +30,15 @@ func main() { cm3.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { totalReqs.WithLabelValues().Inc() + refresh := "" if strings.Contains(r.Host, ".") && !strings.Contains(r.Host, ":") { var url = url.URL{Host: r.Host, Scheme: "https", Path: r.URL.Path} w.Header().Add("Location", url.String()) w.WriteHeader(301) hostReqs.WithLabelValues().Inc() + refresh = "" } - fmt.Fprintf(w, response) + fmt.Fprintf(w, response, refresh) }) cm3.ListenAndServeHttp(":80", nil) diff --git a/response.html b/response.html index 8a28d09..2aea3d1 100644 --- a/response.html +++ b/response.html @@ -3,8 +3,14 @@ Redirecting... + %s - - Just switch to https up there ↑ + +

+ This site is only available over HTTPS, please use that. +

+ diff --git a/response.min.html b/response.min.html index 081a850..049d64e 100644 --- a/response.min.html +++ b/response.min.html @@ -1 +1 @@ -Redirecting...Just switch to https up there ↑ \ No newline at end of file +Redirecting...%s

This site is only available over HTTPS, please use that.

\ No newline at end of file