aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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