diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-07-03 21:29:47 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-07-03 21:29:47 -0700 |
commit | 261c3af05326442ac64ee427861dcba0809cf4a1 (patch) | |
tree | 9cb95723633078ec619c33062cfc520c14da1361 /src/Text | |
parent | 1dbbb2f41a1a4a1f05594392ef1a2cc8818ff53d (diff) | |
download | pandoc-261c3af05326442ac64ee427861dcba0809cf4a1.tar.gz |
CPP workaround for deprecation of parseUrl in http-client.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index af81c49cd..ab1c12a80 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -153,6 +153,9 @@ import Paths_pandoc (getDataFileName) import Network.HTTP.Client (httpLbs, parseUrl, responseBody, responseHeaders, Request(port,host)) +#if MIN_VERSION_http_client(0,4,30) +import Network.HTTP.Client (parseRequest) +#endif #if MIN_VERSION_http_client(0,4,18) import Network.HTTP.Client (newManager) #else @@ -946,13 +949,18 @@ openURL u in return $ Right (decodeLenient contents, Just mime) #ifdef HTTP_CLIENT | otherwise = withSocketsDo $ E.try $ do - req <- parseUrl u +#if MIN_VERSION_http_client(0,4,30) + let parseReq = parseRequest +#else + let parseReq = parseUrl +#endif (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy" - let req' = case proxy of - Left _ -> req - Right pr -> case parseUrl pr of - Just r -> addProxy (host r) (port r) req - Nothing -> req + req <- parseReq u + req' <- case proxy of + Left _ -> return req + Right pr -> (parseReq pr >>= \r -> + return $ addProxy (host r) (port r) req) + `mplus` return req #if MIN_VERSION_http_client(0,4,18) resp <- newManager tlsManagerSettings >>= httpLbs req' #else |