mirror of
https://github.com/docker/docs.git
synced 2026-04-05 02:38:52 +07:00
refresh before closing the connection
Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user