mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +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{}
|
||||
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)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
gpath "path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"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) {
|
||||
// Remove "; charset=" if included in header.
|
||||
if idx := strings.Index(contentType, ";"); idx > 0 {
|
||||
contentType = contentType[:idx]
|
||||
}
|
||||
patchType := api.PatchType(contentType)
|
||||
switch patchType {
|
||||
case api.JSONPatchType:
|
||||
|
Loading…
Reference in New Issue
Block a user