parent
abf628d2bb
commit
f083763f1d
|
|
@ -153,11 +153,11 @@ func (s *Server) Pre(foo http.HandlerFunc) http.HandlerFunc {
|
||||||
if auth, err := s.lookupAuth(mapKey(r.Host)); err != nil {
|
if auth, err := s.lookupAuth(mapKey(r.Host)); err != nil {
|
||||||
log.Printf("failed to lookup auth for %s (%s): %v", r.Host, mapKey(r.Host), err)
|
log.Printf("failed to lookup auth for %s (%s): %v", r.Host, mapKey(r.Host), err)
|
||||||
w.Header().Set("WWW-Authenticate", "Basic")
|
w.Header().Set("WWW-Authenticate", "Basic")
|
||||||
http.Error(w, err.Error(), http.StatusForbidden)
|
http.Error(w, err.Error(), http.StatusUnauthorized)
|
||||||
} else if _, p, _ := r.BasicAuth(); auth != p {
|
} else if _, p, _ := r.BasicAuth(); auth != p {
|
||||||
log.Printf("failed to auth: expected %q but got %q", auth, p)
|
log.Printf("failed to auth: expected %q but got %q", auth, p)
|
||||||
w.Header().Set("WWW-Authenticate", "Basic")
|
w.Header().Set("WWW-Authenticate", "Basic")
|
||||||
http.Error(w, "unexpected basic auth", http.StatusForbidden)
|
http.Error(w, "unexpected basic auth", http.StatusUnauthorized)
|
||||||
} else {
|
} else {
|
||||||
foo(w, r)
|
foo(w, r)
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +215,6 @@ func (cb corsResponseWriter) WriteHeader(code int) {
|
||||||
func doCORS(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, bool) {
|
func doCORS(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, bool) {
|
||||||
key := mapKey(r.Host)
|
key := mapKey(r.Host)
|
||||||
if !config.GetCORS(key) {
|
if !config.GetCORS(key) {
|
||||||
pushMeta(r, "do-cors", "not enabled for key")
|
|
||||||
return w, false
|
return w, false
|
||||||
}
|
}
|
||||||
pushMeta(r, "do-cors", "enabled for key")
|
pushMeta(r, "do-cors", "enabled for key")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue