Quellcode durchsuchen

Fix panic in hijack

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass vor 8 Jahren
Ursprung
Commit
7a53991bd6
1 geänderte Dateien mit 8 neuen und 6 gelöschten Zeilen
  1. 8 6
      client/hijack.go

+ 8 - 6
client/hijack.go

@@ -177,12 +177,14 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e
 
 	// Server hijacks the connection, error 'connection closed' expected
 	resp, err := clientconn.Do(req)
-	if err != nil {
-		return nil, err
-	}
-	if resp.StatusCode != http.StatusSwitchingProtocols {
-		resp.Body.Close()
-		return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode)
+	if err != httputil.ErrPersistEOF {
+		if err != nil {
+			return nil, err
+		}
+		if resp.StatusCode != http.StatusSwitchingProtocols {
+			resp.Body.Close()
+			return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode)
+		}
 	}
 
 	c, br := clientconn.Hijack()