Removed dependency on conduit.
* http-conduit flag is now https. * Instead of http-conduit, we depend on http-client and http-client-tls.
This commit is contained in:
parent
0915967d84
commit
ee8c8da8cc
3 changed files with 16 additions and 14 deletions
5
INSTALL
5
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:
|
||||
|
||||
|
|
11
pandoc.cabal
11
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue