@@ -49,15 +49,15 @@ setRQBody :: ByteString -> Req -> Req
4949setRQBody b req = req { reqBody = b }
5050
5151reqToRequest :: (Functor m, MonadThrow m) => Req -> BaseUrl -> m Request
52−reqToRequest req (BaseUrl scheme host port) = fmap (setrqb . setQS ) $ parseUrl url
52+reqToRequest req (BaseUrl reqScheme reqHost reqPort) = fmap (setrqb . setQS ) $ parseUrl url
5353
54− where url = show $ nullURI { uriScheme = case scheme of
54+ where url = show $ nullURI { uriScheme = case reqScheme of
5555 Http -> "http:"
5656 Https -> "https:"
5757 , uriAuthority = Just $
5858 URIAuth { uriUserInfo = ""
59− , uriRegName = host
60− , uriPort = ":" ++ show port
59+ , uriRegName = reqHost
60+ , uriPort = ":" ++ show reqPort
6161 }
6262 , uriPath = reqPath req
6363 }
@@ -79,14 +79,14 @@ __withGlobalManager action = modifyMVar __manager $ \ manager -> do
7979
8080
8181displayHttpRequest :: Method -> String
82−displayHttpRequest method = "HTTP " ++ cs method ++ " request"
82+displayHttpRequest httpmethod = "HTTP " ++ cs httpmethod ++ " request"
8383
8484
8585performRequest :: Method -> Req -> (Int -> Bool) -> BaseUrl -> EitherT String IO (Int, ByteString)
86−performRequest method req isWantedStatus host = do
87− partialRequest <- liftIO $ reqToRequest req host
86+performRequest reqMethod req isWantedStatus reqHost = do
87+ partialRequest <- liftIO $ reqToRequest req reqHost
8888
89− let request = partialRequest { Client.method = method
89+ let request = partialRequest { Client.method = reqMethod
9090 , checkStatus = \ _status _headers _cookies -> Nothing
9191 }
9292
@@ -95,12 +95,12 @@ performRequest method req isWantedStatus host = do
9595 Client.httpLbs request manager
9696 case eResponse of
9797 Left status ->
98− left (displayHttpRequest method ++ " failed with status: " ++ showStatus status)
98+ left (displayHttpRequest reqMethod ++ " failed with status: " ++ showStatus status)
9999
100100 Right response -> do
101101 let status = Client.responseStatus response
102102 unless (isWantedStatus (statusCode status)) $
103− left (displayHttpRequest method ++ " failed with status: " ++ showStatus status)
103+ left (displayHttpRequest reqMethod ++ " failed with status: " ++ showStatus status)
104104 return $ (statusCode status, Client.responseBody response)
105105 where
106106 showStatus (Status code message) =
@@ -109,20 +109,20 @@ performRequest method req isWantedStatus host = do
109109
110110performRequestJSON :: FromJSON result =>
111111 Method -> Req -> Int -> BaseUrl -> EitherT String IO result
112−performRequestJSON method req wantedStatus host = do
113− (_status, responseBody) <- performRequest method req (== wantedStatus) host
112+performRequestJSON reqMethod req wantedStatus reqHost = do
113+ (_status, respBody) <- performRequest reqMethod req (== wantedStatus) reqHost
114114 either
115− (\ message -> left (displayHttpRequest method ++ " returned invalid json: " ++ message))
115+ (\ message -> left (displayHttpRequest reqMethod ++ " returned invalid json: " ++ message))
116116 return
117− (decodeLenient responseBody)
117+ (decodeLenient respBody)
118118
119119
120120catchStatusCodeException :: IO a -> IO (Either Status a)
121−catchStatusCodeException action = catch (Right <$> action) $
122− \ e -> case e of
123− Client.StatusCodeException status _ _ ->
124− return $ Left status
125− e -> throwIO e
121+catchStatusCodeException action =
122+ catch (Right <$> action) $ \e ->
123+ case e of
124+ Client.StatusCodeException status _ _ -> return $ Left status
125+ exc -> throwIO exc
126126
127127-- | Like 'Data.Aeson.decode' but allows all JSON values instead of just
128128-- objects and arrays.