Check HTTP auth before allowing CONNECT

This commit is contained in:
Andrew Gaul 2017-08-20 21:57:07 -07:00
parent defbc287f1
commit 703cb4adaf
1 changed files with 4 additions and 4 deletions

View File

@ -82,10 +82,6 @@ func (p *Proxy) checkHttpBasicAuth(auth string) bool {
}
func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
if r.Method == "CONNECT" {
return p.handleConnect(w, r)
}
// TODO: only HTTPS?
if p.user != "" {
if !p.checkHttpBasicAuth(r.Header.Get("Proxy-Authorization")) {
@ -95,6 +91,10 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
}
}
if r.Method == "CONNECT" {
return p.handleConnect(w, r)
}
resp, err := forward(r)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)