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:
John MacFarlane 2014-05-18 22:04:39 -07:00
parent 0915967d84
commit ee8c8da8cc
3 changed files with 16 additions and 14 deletions

View file

@ -116,9 +116,8 @@ assume that the pandoc source directory is your working directory.
cabal install hsb2hs cabal install hsb2hs
- `http-conduit`: use the `http-conduit` library to fetch external - `https`: enable support for downloading resources over https
resources (default yes -- without this, pandoc cannot make SSL (using the `http-client` and `http-client-tls` libraries).
connections)
3. Build: 3. Build:

View file

@ -196,8 +196,8 @@ Flag embed_data_files
Description: Embed data files in binary for relocatable executable. Description: Embed data files in binary for relocatable executable.
Default: False Default: False
Flag http-conduit Flag https
Description: Enable downloading of resources over https. Description: Enable support for downloading of resources over https.
Default: True Default: True
Library Library
@ -239,10 +239,11 @@ Library
hslua >= 0.3 && < 0.4, hslua >= 0.3 && < 0.4,
binary >= 0.5 && < 0.8 binary >= 0.5 && < 0.8
Build-Tools: alex, happy Build-Tools: alex, happy
if flag(http-conduit) if flag(https)
Build-Depends: http-conduit >= 1.9 && < 2.2, Build-Depends: http-client >= 0.3.2 && < 0.4,
http-client-tls >= 0.2 && < 0.3,
http-types >= 0.8 && < 0.9 http-types >= 0.8 && < 0.9
cpp-options: -DHTTP_CONDUIT cpp-options: -DHTTP_CLIENT
if flag(embed_data_files) if flag(embed_data_files)
cpp-options: -DEMBED_DATA_FILES cpp-options: -DEMBED_DATA_FILES
-- Build-Tools: hsb2hs -- not yet recognized by cabal -- Build-Tools: hsb2hs -- not yet recognized by cabal

View file

@ -118,11 +118,13 @@ import System.FilePath ( joinPath, splitDirectories )
#else #else
import Paths_pandoc (getDataFileName) import Paths_pandoc (getDataFileName)
#endif #endif
#ifdef HTTP_CONDUIT #ifdef HTTP_CLIENT
import Data.ByteString.Lazy (toChunks) import Data.ByteString.Lazy (toChunks)
import Network.HTTP.Conduit (httpLbs, parseUrl, withManager, import Network.HTTP.Client (httpLbs, parseUrl, withManager,
responseBody, responseHeaders, addProxy, responseBody, responseHeaders,
Request(port,host)) Request(port,host))
import Network.HTTP.Client.Internal (addProxy)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import System.Environment (getEnv) import System.Environment (getEnv)
import Network.HTTP.Types.Header ( hContentType) import Network.HTTP.Types.Header ( hContentType)
import Network (withSocketsDo) import Network (withSocketsDo)
@ -665,7 +667,7 @@ openURL u
let mime = takeWhile (/=',') $ drop 5 u let mime = takeWhile (/=',') $ drop 5 u
contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u
in return $ Right (decodeLenient contents, Just mime) in return $ Right (decodeLenient contents, Just mime)
#ifdef HTTP_CONDUIT #ifdef HTTP_CLIENT
| otherwise = withSocketsDo $ E.try $ do | otherwise = withSocketsDo $ E.try $ do
req <- parseUrl u req <- parseUrl u
(proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy" (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy"
@ -674,7 +676,7 @@ openURL u
Right pr -> case parseUrl pr of Right pr -> case parseUrl pr of
Just r -> addProxy (host r) (port r) req Just r -> addProxy (host r) (port r) req
Nothing -> req Nothing -> req
resp <- withManager $ httpLbs req' resp <- withManager tlsManagerSettings $ httpLbs req'
return (BS.concat $ toChunks $ responseBody resp, return (BS.concat $ toChunks $ responseBody resp,
UTF8.toString `fmap` lookup hContentType (responseHeaders resp)) UTF8.toString `fmap` lookup hContentType (responseHeaders resp))
#else #else