From d45c7c58973a8d59533a153d4ee667f08cb8671d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Hahn?= Date: Sat, 9 Jul 2016 13:31:58 +0200 Subject: [PATCH] support http-client-0.5 --- servant-client/servant-client.cabal | 4 ++-- servant-client/src/Servant/Common/Req.hs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index ce98c41c..a067c2e3 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -42,8 +42,8 @@ library , bytestring >= 0.10 && < 0.11 , exceptions >= 0.8 && < 0.9 , http-api-data >= 0.1 && < 0.3 - , http-client >= 0.4.18.1 && < 0.5 - , http-client-tls >= 0.2.2 && < 0.3 + , http-client >= 0.4.18.1 && < 0.6 + , http-client-tls >= 0.2.2 && < 0.4 , http-media >= 0.6.2 && < 0.7 , http-types >= 0.8.6 && < 0.10 , network-uri >= 2.6 && < 2.7 diff --git a/servant-client/src/Servant/Common/Req.hs b/servant-client/src/Servant/Common/Req.hs index 1dedde71..6d922634 100644 --- a/servant-client/src/Servant/Common/Req.hs +++ b/servant-client/src/Servant/Common/Req.hs @@ -147,9 +147,8 @@ performRequest :: Method -> Req -> Manager -> BaseUrl performRequest reqMethod req manager reqHost = do partialRequest <- liftIO $ reqToRequest req reqHost - let request = partialRequest { Client.method = reqMethod - , checkStatus = \ _status _headers _cookies -> Nothing - } + let request = disableStatusCheck $ + partialRequest { Client.method = reqMethod } eResponse <- liftIO $ catchConnectionError $ Client.httpLbs request manager case eResponse of @@ -170,6 +169,12 @@ performRequest reqMethod req manager reqHost = do throwE $ FailureResponse status ct body return (status_code, body, ct, hdrs, response) +disableStatusCheck :: Request -> Request +#if MIN_VERSION_http_client(0,5,0) +disableStatusCheck req = req { checkResponse = \ _req _res -> return () } +#else +disableStatusCheck req = req { checkStatus = \ _status _headers _cookies -> Nothing } +#endif performRequestCT :: MimeUnrender ct result => Proxy ct -> Method -> Req -> Manager -> BaseUrl