summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-07-03 21:29:47 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2016-07-03 21:29:47 -0700
commit261c3af05326442ac64ee427861dcba0809cf4a1 (patch)
tree9cb95723633078ec619c33062cfc520c14da1361
parent1dbbb2f41a1a4a1f05594392ef1a2cc8818ff53d (diff)
CPP workaround for deprecation of parseUrl in http-client.
-rw-r--r--src/Text/Pandoc/Shared.hs20
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