aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r--src/Text/Pandoc/Shared.hs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index af81c49cd..9c6c4b33f 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -150,9 +150,13 @@ import Text.Pandoc.Data (dataFiles)
import Paths_pandoc (getDataFileName)
#endif
#ifdef HTTP_CLIENT
-import Network.HTTP.Client (httpLbs, parseUrl,
- responseBody, responseHeaders,
+import Network.HTTP.Client (httpLbs, responseBody, responseHeaders,
Request(port,host))
+#if MIN_VERSION_http_client(0,4,30)
+import Network.HTTP.Client (parseRequest)
+#else
+import Network.HTTP.Client (parseUrl)
+#endif
#if MIN_VERSION_http_client(0,4,18)
import Network.HTTP.Client (newManager)
#else
@@ -946,13 +950,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