Skip to content

Commit

Permalink
Shared.openURL: Print diagnostic output to stderr, not stdout.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed May 1, 2013
1 parent 9cdc9a7 commit effc6a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Text/Pandoc/Shared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
import qualified Data.ByteString as B
import Network.HTTP (findHeader, rspBody,
RequestMethod(..), HeaderName(..), mkRequest)
import Network.Browser (browse, setAllowRedirects, request)
import Network.Browser (browse, setAllowRedirects, setOutHandler, request)
#ifdef EMBED_DATA_FILES
import Text.Pandoc.Data (dataFiles)
import System.FilePath ( joinPath, splitDirectories )
Expand Down Expand Up @@ -567,8 +567,10 @@ fetchItem sourceDir s =

-- | Read from a URL and return raw data and maybe mime type.
openURL :: String -> IO (B.ByteString, Maybe String)
openURL u = getBodyAndMimeType `fmap`
browse (setAllowRedirects True >> request (getRequest' u'))
openURL u = getBodyAndMimeType `fmap` browse
(do setOutHandler (UTF8.hPutStrLn stderr)
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: " ++
Expand Down

0 comments on commit effc6a9

Please sign in to comment.