Fix a bug in onlyJsonObjects that made it fail if there was no
content-type.
This commit is contained in:
parent
e3bf044741
commit
9743ac5ec4
@ -84,15 +84,13 @@ notLongerThan maxAllowed
|
|||||||
-- /Since 0.0.0.0/
|
-- /Since 0.0.0.0/
|
||||||
onlyJsonObjects :: ResponsePredicate
|
onlyJsonObjects :: ResponsePredicate
|
||||||
onlyJsonObjects
|
onlyJsonObjects
|
||||||
= ResponsePredicate (\resp -> case go resp of
|
= ResponsePredicate (\resp -> do
|
||||||
Nothing -> throw $ PredicateFailure "onlyJsonObjects" Nothing resp
|
case lookup "content-type" (first foldedCase <$> responseHeaders resp) of
|
||||||
Just () -> return ())
|
Nothing -> return ()
|
||||||
where
|
Just ctype -> when ("application/json" `SBS.isPrefixOf` ctype) $ do
|
||||||
go r = do
|
case (decode (responseBody resp) :: Maybe Object) of
|
||||||
ctyp <- lookup "content-type" (first foldedCase <$> responseHeaders r)
|
Nothing -> throw $ PredicateFailure "onlyJsonObjects" Nothing resp
|
||||||
when ("application/json" `SBS.isPrefixOf` ctyp) $ do
|
Just _ -> return ())
|
||||||
(_ :: Object) <- decode (responseBody r)
|
|
||||||
return ()
|
|
||||||
|
|
||||||
-- | __Optional__
|
-- | __Optional__
|
||||||
--
|
--
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user