Skip to content

Commit

Permalink
Fix parsing the media type in GameServerAllocation (googleforgames#1749)
Browse files Browse the repository at this point in the history
Add a call to filter out optional parameters send in an HTTP header.
  • Loading branch information
aLekSer authored and ilkercelikyilmaz committed Oct 23, 2020
1 parent 5ff2537 commit aaad86e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/gameserverallocations/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gameserverallocations
import (
"context"
"io/ioutil"
"mime"
"net/http"
"time"

Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit aaad86e

Please sign in to comment.