mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #14874 from derekparker/fix-json-patch-content-type
Auto commit by PR queue bot
This commit is contained in:
commit
a413fd278f
@ -1665,7 +1665,7 @@ func TestPatch(t *testing.T) {
|
|||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
request, err := http.NewRequest("PATCH", server.URL+"/api/version/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
request, err := http.NewRequest("PATCH", server.URL+"/api/version/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`)))
|
||||||
request.Header.Set("Content-Type", "application/merge-patch+json")
|
request.Header.Set("Content-Type", "application/merge-patch+json; charset=UTF-8")
|
||||||
_, err = client.Do(request)
|
_, err = client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
gpath "path"
|
gpath "path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/admission"
|
"k8s.io/kubernetes/pkg/admission"
|
||||||
@ -736,6 +737,10 @@ func setListSelfLink(obj runtime.Object, req *restful.Request, namer ScopeNamer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPatchedJS(contentType string, originalJS, patchJS []byte, obj runtime.Object) ([]byte, error) {
|
func getPatchedJS(contentType string, originalJS, patchJS []byte, obj runtime.Object) ([]byte, error) {
|
||||||
|
// Remove "; charset=" if included in header.
|
||||||
|
if idx := strings.Index(contentType, ";"); idx > 0 {
|
||||||
|
contentType = contentType[:idx]
|
||||||
|
}
|
||||||
patchType := api.PatchType(contentType)
|
patchType := api.PatchType(contentType)
|
||||||
switch patchType {
|
switch patchType {
|
||||||
case api.JSONPatchType:
|
case api.JSONPatchType:
|
||||||
|
Loading…
Reference in New Issue
Block a user