зеркало из https://github.com/microsoft/docker.git
removed hijack in export
This commit is contained in:
Родитель
0ecf5e245d
Коммит
93dc2c331e
11
api.go
11
api.go
|
@ -102,14 +102,9 @@ func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request) ([
|
|||
vars := mux.Vars(r)
|
||||
name := vars["name"]
|
||||
|
||||
in, out, err := hijackServer(w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer in.Close()
|
||||
fmt.Fprintf(out, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
|
||||
if err := srv.ContainerExport(name, out); err != nil {
|
||||
fmt.Fprintf(out, "Error: %s\n", err)
|
||||
if err := srv.ContainerExport(name, w); err != nil {
|
||||
Debugf("%s", err.Error())
|
||||
//return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
|
25
commands.go
25
commands.go
|
@ -865,7 +865,7 @@ func CmdExport(args ...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := hijack("GET", "/containers/"+cmd.Arg(0)+"/export", false); err != nil {
|
||||
if err := stream("GET", "/containers/"+cmd.Arg(0)+"/export"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -1180,6 +1180,29 @@ func call(method, path string, data interface{}) ([]byte, int, error) {
|
|||
return body, resp.StatusCode, nil
|
||||
}
|
||||
|
||||
func stream(method, path string) error {
|
||||
req, err := http.NewRequest(method, "http://0.0.0.0:4243"+path, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
||||
if method == "POST" {
|
||||
req.Header.Set("Content-Type", "plain/text")
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "connection refused") {
|
||||
return fmt.Errorf("Can't connect to docker daemon. Is 'docker -d' running on this host?")
|
||||
}
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if _, err := io.Copy(os.Stdout, resp.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func hijack(method, path string, setRawTerminal bool) error {
|
||||
req, err := http.NewRequest(method, path, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -262,7 +262,7 @@ Export a container
|
|||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/vnd.docker.raw-stream
|
||||
Content-Type: application/octet-stream
|
||||
|
||||
{{ STREAM }}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче