Pass through User-Agent from client

Some servers may redirect clients based on their User-Agent.  Fixes #66.
This commit is contained in:
Web-Distortion 2021-10-19 08:19:19 +08:00 committed by GitHub
parent aaa43454a9
commit 0602293989
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -138,6 +138,8 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
return fmt.Errorf("error forwarding request: %s", err)
}
defer resp.Body.Close()
user_agent = r.Header().Get("User-Agent")
w.Header().Set("User-Agent", user_agent)
rw := newResponseWriter(w)
rr := newResponseReader(resp)
err = p.proxyResponse(rw, rr, r.Header)