Skip to content

Commit

Permalink
Implement ReverseProxy request cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
pwaller committed Dec 30, 2014
1 parent f3de217 commit 7fd9ecc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/net/http/httputil/reverseproxy.go
Expand Up @@ -109,6 +109,21 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
outreq := new(http.Request)
*outreq = *req // includes shallow copies of maps, but okay

go func() {
cn, ok := rw.(http.CloseNotifier)
if !ok {
// In this case, rw may have been wrapped and there is nothing
// that can be done.
return
}
<-cn.CloseNotify()
t, ok := transport.(*http.Transport)
if !ok {
return
}
t.CancelRequest(outreq)
}()

p.Director(outreq)
outreq.Proto = "HTTP/1.1"
outreq.ProtoMajor = 1
Expand Down

0 comments on commit 7fd9ecc

Please sign in to comment.