[proxy] Only replace the request body if we've modified it.
This is a temporary fix for a failure in docker-py tests: "test_valid_no_config_specified".
This commit is contained in:
1 parent
7652b44c21
commit
6b5f35e574
2 files changed
+12
-9
No files matched your search
@@ -45,6 +45,7 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
|
r.Body = ioutil.NopCloser(bytes.NewReader(body))
|
||||||
|
|
||||||
container := createContainerRequestBody{}
|
container := createContainerRequestBody{}
|
||||||
if err := json.Unmarshal(body, &container); err != nil {
|
if err := json.Unmarshal(body, &container); err != nil {
|
||||||
@@ -68,14 +69,14 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
if err := i.setWeaveDNS(&container, r); err != nil {
|
if err := i.setWeaveDNS(&container, r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
newBody, err := json.Marshal(container)
|
newBody, err := json.Marshal(container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
r.Body = ioutil.NopCloser(bytes.NewReader(newBody))
|
||||||
|
r.ContentLength = int64(len(newBody))
|
||||||
}
|
}
|
||||||
r.Body = ioutil.NopCloser(bytes.NewReader(newBody))
|
|
||||||
r.ContentLength = int64(len(newBody))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -18,6 +19,7 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
|
r.Body = ioutil.NopCloser(bytes.NewReader(body))
|
||||||
|
|
||||||
options := docker.CreateExecOptions{}
|
options := docker.CreateExecOptions{}
|
||||||
if err := json.Unmarshal(body, &options); err != nil {
|
if err := json.Unmarshal(body, &options); err != nil {
|
||||||
@@ -37,10 +39,10 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
Info.Printf("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
|
Info.Printf("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " "))
|
||||||
cmd := append(weaveWaitEntrypoint, "-s")
|
cmd := append(weaveWaitEntrypoint, "-s")
|
||||||
options.Cmd = append(cmd, options.Cmd...)
|
options.Cmd = append(cmd, options.Cmd...)
|
||||||
}
|
|
||||||
|
|
||||||
if err := marshalRequestBody(r, options); err != nil {
|
if err := marshalRequestBody(r, options); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in new issue
Block a user