refresh before closing the connection

Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
This commit is contained in:
Xian Chaobo 2015-05-18 04:52:37 -04:00
parent ada8208157
commit 014947daad
2 changed files with 10 additions and 8 deletions

View File

@ -545,12 +545,14 @@ func proxyContainerAndForceRefresh(c *context, w http.ResponseWriter, r *http.Re
r.URL.Path = strings.Replace(r.URL.Path, name, container.Id, 1)
}
if err := proxy(c.tlsConfig, container.Engine.Addr, w, r); err != nil {
httpError(w, err.Error(), http.StatusInternalServerError)
cb := func(resp *http.Response) {
// force fresh container
container.Refresh()
}
// force fresh container
container.Refresh()
if err := proxyAsync(c.tlsConfig, container.Engine.Addr, w, r, cb); err != nil {
httpError(w, err.Error(), http.StatusInternalServerError)
}
}
// Proxy a request to the right node

View File

@ -81,14 +81,14 @@ func proxyAsync(tlsConfig *tls.Config, addr string, w http.ResponseWriter, r *ht
w.WriteHeader(resp.StatusCode)
io.Copy(NewWriteFlusher(w), resp.Body)
// cleanup
resp.Body.Close()
closeIdleConnections(client)
if callback != nil {
callback(resp)
}
// cleanup
resp.Body.Close()
closeIdleConnections(client)
return nil
}