-
-
Notifications
You must be signed in to change notification settings - Fork 418
Description
In Servant.Client.Core.Internal.RunClient
, we find
decodedAs :: forall ct a m. (MimeUnrender ct a, RunClient m)
=> Response -> Proxy ct -> m a
decodedAs response contentType = do
responseContentType <- checkContentTypeHeader response
unless (any (matches responseContentType) accept) $
throwServantError $ UnsupportedContentType responseContentType response
case mimeUnrender contentType $ responseBody response of
Left err -> throwServantError $ DecodeFailure (T.pack err) response
Right val -> return val
where
accept = toList $ contentTypes contentType
I think the line
unless (any (matches responseContentType) accept) $
is wrong. The documentation for matches
reads
This relation must be a total order, where more specific terms on the left can produce a match, but a less specific term on the left can never produce a match. For instance, when matching against media types it is important that if the client asks for a general type then we can choose a more specific offering from the server, but if a client asks for a specific type and the server only offers a more general form, then we cannot generalise. In this case, the server types will be the left argument, and the client types the right.
Here however the client type is given on the left instead.
The result is that for a client that accepts a HTML response (accept
will be [text/html;charset=utf-8]
) but a server that returns a content-type of text/html
, the response is rejected as UnsupportedContentType
.