Merge pull request #14874 from derekparker/fix-json-patch-content-type

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2015-10-02 07:08:58 -07:00
commit a413fd278f
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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: