fix: regression that replaces an unknown media type with */* (#4013)
This commit is contained in:
@@ -155,7 +155,7 @@ decodeMediaType mt = decodeMediaType' $ decodeLatin1 mt
|
||||
mediaTypeOrError = P.parse tokenizeMediaType "parsec: tokenizeMediaType failed" $ T.unpack mt'
|
||||
(mainType, subType, params') = case mediaTypeOrError of
|
||||
Right mt'' -> mt''
|
||||
Left _ -> ("*", "*", []) -- TODO: Throw mediatype error, would need refactoring because currently Error module depend on MediaType module
|
||||
Left _ -> (mt',"",[])
|
||||
params = fromList $ map (first T.toLower) params' -- normalize parameter names to lowercase, per RFC 7321
|
||||
getPlan fmt = MTVndPlan mtFor fmt $
|
||||
[PlanAnalyze | inOpts "analyze" ] ++
|
||||
|
||||
@@ -375,3 +375,10 @@ spec = describe "custom media types" $ do
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "application/octet-stream"]
|
||||
}
|
||||
|
||||
context "media type parser fails" $ do
|
||||
it "sends media type as is" $
|
||||
request methodGet "/items" (acceptHdrs "undefined") ""
|
||||
`shouldRespondWith`
|
||||
[json| {"code":"PGRST107","details":null,"hint":null,"message":"None of these media types are available: undefined"} |]
|
||||
{ matchStatus = 406 }
|
||||
|
||||
Reference in New Issue
Block a user