fix http requests over https proxy connection

Reconstruct the schema of the proxied request if it's not filled out.
This commit is contained in:
Barna Csorogi 2016-03-26 19:02:40 +01:00
parent a4a691b7b8
commit fd53c9cb8c

View file

@ -66,7 +66,11 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
func forward(r *http.Request) (*http.Response, error) {
if r.URL.Scheme == "" {
if r.TLS != nil && r.TLS.ServerName == r.Host {
r.URL.Scheme = "https"
} else {
r.URL.Scheme = "http"
}
}
if r.URL.Host == "" {
r.URL.Host = r.Host