...
1
2
3
4
5 package vcweb
6
7 import (
8 "log"
9 "net/http"
10 )
11
12
13
14 type insecureHandler struct{}
15
16 func (h *insecureHandler) Available() bool { return true }
17
18 func (h *insecureHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) {
19
20
21
22
23 return h, nil
24 }
25
26 func (h *insecureHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
27 if req.Host == "" && req.URL.Host == "" {
28 http.Error(w, "no Host provided in request", http.StatusBadRequest)
29 return
30 }
31
32
33
34
35
36 u := *req.URL
37 u.Scheme = "http"
38 u.User = nil
39 u.Host = req.Host
40
41 http.Redirect(w, req, u.String(), http.StatusFound)
42 }
43
View as plain text