diff --git a/INSTALL b/INSTALL index 9442adbf0..f3366e103 100644 --- a/INSTALL +++ b/INSTALL @@ -116,9 +116,8 @@ assume that the pandoc source directory is your working directory. cabal install hsb2hs - - `http-conduit`: use the `http-conduit` library to fetch external - resources (default yes -- without this, pandoc cannot make SSL - connections) + - `https`: enable support for downloading resources over https + (using the `http-client` and `http-client-tls` libraries). 3. Build: diff --git a/pandoc.cabal b/pandoc.cabal index 6f12ec375..1741c59f6 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -196,8 +196,8 @@ Flag embed_data_files Description: Embed data files in binary for relocatable executable. Default: False -Flag http-conduit - Description: Enable downloading of resources over https. +Flag https + Description: Enable support for downloading of resources over https. Default: True Library @@ -239,10 +239,11 @@ Library hslua >= 0.3 && < 0.4, binary >= 0.5 && < 0.8 Build-Tools: alex, happy - if flag(http-conduit) - Build-Depends: http-conduit >= 1.9 && < 2.2, + if flag(https) + Build-Depends: http-client >= 0.3.2 && < 0.4, + http-client-tls >= 0.2 && < 0.3, http-types >= 0.8 && < 0.9 - cpp-options: -DHTTP_CONDUIT + cpp-options: -DHTTP_CLIENT if flag(embed_data_files) cpp-options: -DEMBED_DATA_FILES -- Build-Tools: hsb2hs -- not yet recognized by cabal diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 4f506b5a6..d8cbe46d9 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -118,11 +118,13 @@ import System.FilePath ( joinPath, splitDirectories ) #else import Paths_pandoc (getDataFileName) #endif -#ifdef HTTP_CONDUIT +#ifdef HTTP_CLIENT import Data.ByteString.Lazy (toChunks) -import Network.HTTP.Conduit (httpLbs, parseUrl, withManager, - responseBody, responseHeaders, addProxy, - Request(port,host)) +import Network.HTTP.Client (httpLbs, parseUrl, withManager, + responseBody, responseHeaders, + Request(port,host)) +import Network.HTTP.Client.Internal (addProxy) +import Network.HTTP.Client.TLS (tlsManagerSettings) import System.Environment (getEnv) import Network.HTTP.Types.Header ( hContentType) import Network (withSocketsDo) @@ -665,7 +667,7 @@ openURL u let mime = takeWhile (/=',') $ drop 5 u contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u in return $ Right (decodeLenient contents, Just mime) -#ifdef HTTP_CONDUIT +#ifdef HTTP_CLIENT | otherwise = withSocketsDo $ E.try $ do req <- parseUrl u (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy" @@ -674,7 +676,7 @@ openURL u Right pr -> case parseUrl pr of Just r -> addProxy (host r) (port r) req Nothing -> req - resp <- withManager $ httpLbs req' + resp <- withManager tlsManagerSettings $ httpLbs req' return (BS.concat $ toChunks $ responseBody resp, UTF8.toString `fmap` lookup hContentType (responseHeaders resp)) #else