From ac94465829e29704347b6697cdedd43614617f06 Mon Sep 17 00:00:00 2001 From: alekser Date: Thu, 13 Aug 2020 09:06:54 +0000 Subject: [PATCH] Fix parsing the media type in GameServerAllocation Add a call to filter out optional parameters send in an HTTP header. --- pkg/gameserverallocations/controller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/gameserverallocations/controller.go b/pkg/gameserverallocations/controller.go index 546a37287c..13cf5ba0a9 100644 --- a/pkg/gameserverallocations/controller.go +++ b/pkg/gameserverallocations/controller.go @@ -17,6 +17,7 @@ package gameserverallocations import ( "context" "io/ioutil" + "mime" "net/http" "time" @@ -175,7 +176,11 @@ func (c *Controller) allocationDeserialization(r *http.Request, namespace string gsa.TypeMeta = metav1.TypeMeta{Kind: gvks[0].Kind, APIVersion: gvks[0].Version} mediaTypes := scheme.Codecs.SupportedMediaTypes() - info, ok := k8sruntime.SerializerInfoForMediaType(mediaTypes, r.Header.Get("Content-Type")) + mt, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return gsa, errors.Wrap(err, "error parsing mediatype from a request header") + } + info, ok := k8sruntime.SerializerInfoForMediaType(mediaTypes, mt) if !ok { return gsa, errors.New("Could not find deserializer") }