Check the content type is json when calling exec start.
Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
parent
841205ec01
commit
45dc57f229
3 changed files with 9 additions and 2 deletions
|
@ -92,7 +92,7 @@ func (cli *DockerCli) CmdExec(args ...string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errCh = promise.Go(func() error {
|
errCh = promise.Go(func() error {
|
||||||
return cli.hijack("POST", "/exec/"+execID+"/start", execConfig.Tty, in, out, stderr, hijacked, execConfig)
|
return cli.hijackWithContentType("POST", "/exec/"+execID+"/start", "application/json", execConfig.Tty, in, out, stderr, hijacked, execConfig)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Acknowledge the hijack before starting
|
// Acknowledge the hijack before starting
|
||||||
|
|
|
@ -127,6 +127,10 @@ func (cli *DockerCli) dial() (net.Conn, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, data interface{}) error {
|
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, data interface{}) error {
|
||||||
|
return cli.hijackWithContentType(method, path, "text/plain", setRawTerminal, in, stdout, stderr, started, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cli *DockerCli) hijackWithContentType(method, path, contentType string, setRawTerminal bool, in io.ReadCloser, stdout, stderr io.Writer, started chan io.Closer, data interface{}) error {
|
||||||
defer func() {
|
defer func() {
|
||||||
if started != nil {
|
if started != nil {
|
||||||
close(started)
|
close(started)
|
||||||
|
@ -149,7 +153,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION+" ("+runtime.GOOS+")")
|
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION+" ("+runtime.GOOS+")")
|
||||||
req.Header.Set("Content-Type", "text/plain")
|
req.Header.Set("Content-Type", contentType)
|
||||||
req.Header.Set("Connection", "Upgrade")
|
req.Header.Set("Connection", "Upgrade")
|
||||||
req.Header.Set("Upgrade", "tcp")
|
req.Header.Set("Upgrade", "tcp")
|
||||||
req.Host = cli.addr
|
req.Host = cli.addr
|
||||||
|
|
|
@ -60,6 +60,9 @@ func (s *router) postContainerExecStart(ctx context.Context, w http.ResponseWrit
|
||||||
if err := httputils.ParseForm(r); err != nil {
|
if err := httputils.ParseForm(r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := httputils.CheckForJSON(r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
execName = vars["name"]
|
execName = vars["name"]
|
||||||
stdin, inStream io.ReadCloser
|
stdin, inStream io.ReadCloser
|
||||||
|
|
Loading…
Reference in a new issue