on master help sign in
Check for correct content-type in result.
commite6e67b275bd0a32f966d93f25566b6a437aa9163 authorTimo von Holtz <tvh@anchor.com.au> dateTue 17 Feb 2015, 10:55 (12 years ago) parentdb2c5a4
1 file changed+3−1
src/Servant/Common/Req.hs+3−1
src/Servant/Common/Req.hs+3−1
@@ -142,7 +142,9 @@ performRequest reqMethod req isWantedStatus reqHost = do
142142performRequestJSON :: FromJSON result =>
143143 Method -> Req -> Int -> BaseUrl -> EitherT String IO result
144144performRequestJSON reqMethod req wantedStatus reqHost = do
145− (_status, respBody, _) <- performRequest reqMethod req (== wantedStatus) reqHost
145+ (_status, respBody, contentType) <- performRequest reqMethod req (== wantedStatus) reqHost
146+ unless (matches contentType ("application"//"json")) $
147+ left $ "requested Content-Type application/json, but got " <> show contentType
146148 either
147149 (\ message -> left (displayHttpRequest reqMethod ++ " returned invalid json: " ++ message))
148150 return