Remove https flag.

Supporting two completely different libraries for fetching
from URLs makes it difficult to trap errors, because of
different error types expected from the libraries.

There's no clear reason not to build with these https-capable
libraires.
This commit is contained in:
John MacFarlane 2017-05-07 12:49:25 +02:00
parent f8e125f42d
commit d414b2543a
5 changed files with 4 additions and 34 deletions

View file

@ -264,10 +264,6 @@ Flag weigh-pandoc
Description: Build weigh-pandoc to measure memory usage.
Default: False
Flag https
Description: Enable support for downloading of resources over https.
Default: True
Flag network-uri
Description: Get Network.URI from the network-uri package
Default: True
@ -316,7 +312,10 @@ Library
JuicyPixels >= 3.1.6.1 && < 3.3,
Glob >= 0.7 && < 0.8,
cmark >= 0.5 && < 0.6,
doctemplates >= 0.1 && < 0.2
doctemplates >= 0.1 && < 0.2,
http-client >= 0.4.30 && < 0.6,
http-client-tls >= 0.2.4 && < 0.4,
http-types >= 0.8 && < 0.10
if os(windows)
Cpp-options: -D_WINDOWS
else
@ -330,11 +329,6 @@ Library
Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6
else
Build-Depends: network >= 2 && < 2.6
if flag(https)
Build-Depends: http-client >= 0.4.30 && < 0.6,
http-client-tls >= 0.2.4 && < 0.4,
http-types >= 0.8 && < 0.10
cpp-options: -DHTTP_CLIENT
if flag(embed_data_files)
cpp-options: -DEMBED_DATA_FILES
build-depends: file-embed >= 0.0 && < 0.1

View file

@ -140,7 +140,6 @@ import Text.Pandoc.Data (dataFiles)
#else
import Paths_pandoc (getDataFileName)
#endif
#ifdef HTTP_CLIENT
import Network.HTTP.Client (httpLbs, responseBody, responseHeaders,
Request(port,host,requestHeaders))
import Network.HTTP.Client (parseRequest)
@ -150,12 +149,6 @@ import Network.HTTP.Client.TLS (tlsManagerSettings)
import System.Environment (getEnv)
import Network.HTTP.Types.Header ( hContentType, hUserAgent)
import Network (withSocketsDo)
#else
import Network.URI (parseURI)
import Network.HTTP (findHeader, rspBody,
RequestMethod(..), HeaderName(..), mkRequest)
import Network.Browser (browse, setAllowRedirects, setOutHandler, request)
#endif
-- | Version number of pandoc library.
pandocVersion :: String
@ -715,7 +708,6 @@ openURL u
let mime = takeWhile (/=',') u''
contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u''
in return (decodeLenient contents, Just mime)
#ifdef HTTP_CLIENT
| otherwise = withSocketsDo $ do
let parseReq = parseRequest
(proxy :: Either IOError String) <-
@ -738,19 +730,6 @@ openURL u
resp <- newManager tlsManagerSettings >>= httpLbs req''
return (BS.concat $ toChunks $ responseBody resp,
UTF8.toString `fmap` lookup hContentType (responseHeaders resp))
#else
| otherwise = getBodyAndMimeType `fmap` browse
(do liftIO $ UTF8.hPutStrLn stderr $ "Fetching " ++ u ++ "..."
setOutHandler $ const (return ())
setAllowRedirects True
request (getRequest' u'))
where getBodyAndMimeType (_, r) = (rspBody r, findHeader HdrContentType r)
getRequest' uriString = case parseURI uriString of
Nothing -> error ("Not a valid URL: " ++
uriString)
Just v -> mkRequest GET v
u' = escapeURIString (/= '|') u -- pipes are rejected by Network.URI
#endif
--
-- Error reporting

View file

@ -3,7 +3,6 @@
flags:
pandoc:
trypandoc: false
https: true
embed_data_files: false
old-locale: false
network-uri: true

View file

@ -1,7 +1,6 @@
flags:
pandoc:
trypandoc: false
https: true
embed_data_files: true
old-locale: false
network-uri: true

View file

@ -1,7 +1,6 @@
flags:
pandoc:
trypandoc: false
https: true
embed_data_files: false
old-locale: false
network-uri: true