mirror of https://github.com/docker/docs.git
check status code in exec
Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
This commit is contained in:
parent
fdf74cef2a
commit
28043dfd7d
|
|
@ -325,6 +325,17 @@ func postContainersExec(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
defer resp.Body.Close()
|
||||
defer closeIdleConnections(client)
|
||||
|
||||
// check status code
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
httpError(w, string(body), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
|
|||
Loading…
Reference in New Issue