diff --git a/dynamic/client_test.go b/dynamic/client_test.go index a205514d..979d7fe3 100644 --- a/dynamic/client_test.go +++ b/dynamic/client_test.go @@ -275,6 +275,11 @@ func TestDelete(t *testing.T) { t.Errorf("Delete(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path) } + content := r.Header.Get("Content-Type") + if content != runtime.ContentTypeJSON { + t.Errorf("Delete(%q) got Content-Type %s. wanted %s", tc.name, content, runtime.ContentTypeJSON) + } + w.Header().Set("Content-Type", runtime.ContentTypeJSON) unstructured.UnstructuredJSONScheme.Encode(statusOK, w) }) @@ -323,6 +328,11 @@ func TestDeleteCollection(t *testing.T) { t.Errorf("DeleteCollection(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path) } + content := r.Header.Get("Content-Type") + if content != runtime.ContentTypeJSON { + t.Errorf("DeleteCollection(%q) got Content-Type %s. wanted %s", tc.name, content, runtime.ContentTypeJSON) + } + w.Header().Set("Content-Type", runtime.ContentTypeJSON) unstructured.UnstructuredJSONScheme.Encode(statusOK, w) }) @@ -389,6 +399,11 @@ func TestCreate(t *testing.T) { t.Errorf("Create(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path) } + content := r.Header.Get("Content-Type") + if content != runtime.ContentTypeJSON { + t.Errorf("Create(%q) got Content-Type %s. wanted %s", tc.name, content, runtime.ContentTypeJSON) + } + w.Header().Set("Content-Type", runtime.ContentTypeJSON) data, err := ioutil.ReadAll(r.Body) if err != nil { @@ -466,6 +481,11 @@ func TestUpdate(t *testing.T) { t.Errorf("Update(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path) } + content := r.Header.Get("Content-Type") + if content != runtime.ContentTypeJSON { + t.Errorf("Uppdate(%q) got Content-Type %s. wanted %s", tc.name, content, runtime.ContentTypeJSON) + } + w.Header().Set("Content-Type", runtime.ContentTypeJSON) data, err := ioutil.ReadAll(r.Body) if err != nil { diff --git a/dynamic/simple.go b/dynamic/simple.go index 9ae320d3..65f40fe1 100644 --- a/dynamic/simple.go +++ b/dynamic/simple.go @@ -110,6 +110,7 @@ func (c *dynamicResourceClient) Create(ctx context.Context, obj *unstructured.Un result := c.client.client. Post(). AbsPath(append(c.makeURLSegments(name), subresources...)...). + SetHeader("Content-Type", runtime.ContentTypeJSON). Body(outBytes). SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1). Do(ctx) @@ -145,6 +146,7 @@ func (c *dynamicResourceClient) Update(ctx context.Context, obj *unstructured.Un result := c.client.client. Put(). AbsPath(append(c.makeURLSegments(name), subresources...)...). + SetHeader("Content-Type", runtime.ContentTypeJSON). Body(outBytes). SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1). Do(ctx) @@ -181,6 +183,7 @@ func (c *dynamicResourceClient) UpdateStatus(ctx context.Context, obj *unstructu result := c.client.client. Put(). AbsPath(append(c.makeURLSegments(name), "status")...). + SetHeader("Content-Type", runtime.ContentTypeJSON). Body(outBytes). SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1). Do(ctx) @@ -211,6 +214,7 @@ func (c *dynamicResourceClient) Delete(ctx context.Context, name string, opts me result := c.client.client. Delete(). AbsPath(append(c.makeURLSegments(name), subresources...)...). + SetHeader("Content-Type", runtime.ContentTypeJSON). Body(deleteOptionsByte). Do(ctx) return result.Error() @@ -225,6 +229,7 @@ func (c *dynamicResourceClient) DeleteCollection(ctx context.Context, opts metav result := c.client.client. Delete(). AbsPath(c.makeURLSegments("")...). + SetHeader("Content-Type", runtime.ContentTypeJSON). Body(deleteOptionsByte). SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1). Do(ctx)