diff options
Diffstat (limited to 'libgo/go/net/http/httputil/reverseproxy.go')
-rw-r--r-- | libgo/go/net/http/httputil/reverseproxy.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libgo/go/net/http/httputil/reverseproxy.go b/libgo/go/net/http/httputil/reverseproxy.go index 54411ca..49c120a 100644 --- a/libgo/go/net/http/httputil/reverseproxy.go +++ b/libgo/go/net/http/httputil/reverseproxy.go @@ -90,6 +90,10 @@ func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy { } else { req.URL.RawQuery = targetQuery + "&" + req.URL.RawQuery } + if _, ok := req.Header["User-Agent"]; !ok { + // explicitly disable User-Agent so it's not set to default value + req.Header.Set("User-Agent", "") + } } return &ReverseProxy{Director: director} } @@ -180,9 +184,9 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { outreq.ProtoMinor = 1 outreq.Close = false - // Remove hop-by-hop headers to the backend. Especially + // Remove hop-by-hop headers to the backend. Especially // important is "Connection" because we want a persistent - // connection, regardless of what the client sent to us. This + // connection, regardless of what the client sent to us. This // is modifying the same underlying map from req (shallow // copied above) so we only copy it if necessary. copiedHeaders := false @@ -210,7 +214,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { res, err := transport.RoundTrip(outreq) if err != nil { p.logf("http: proxy error: %v", err) - rw.WriteHeader(http.StatusInternalServerError) + rw.WriteHeader(http.StatusBadGateway) return } @@ -285,13 +289,13 @@ type maxLatencyWriter struct { dst writeFlusher latency time.Duration - lk sync.Mutex // protects Write + Flush + mu sync.Mutex // protects Write + Flush done chan bool } func (m *maxLatencyWriter) Write(p []byte) (int, error) { - m.lk.Lock() - defer m.lk.Unlock() + m.mu.Lock() + defer m.mu.Unlock() return m.dst.Write(p) } @@ -306,9 +310,9 @@ func (m *maxLatencyWriter) flushLoop() { } return case <-t.C: - m.lk.Lock() + m.mu.Lock() m.dst.Flush() - m.lk.Unlock() + m.mu.Unlock() } } } |