packages feed

http-wget 0.0.0 → 0.2.0

raw patch · 2 files changed

+22/−8 lines, 2 filesdep +attemptdep +sybdep +transformersdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: attempt, syb, transformers

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Network.HTTP.Wget: instance Exception WgetError
+ Network.HTTP.Wget: instance Show WgetError
+ Network.HTTP.Wget: instance Typeable WgetError
- Network.HTTP.Wget: wget :: (Monad m) => String -> [(String, String)] -> [(String, String)] -> IO (m String)
+ Network.HTTP.Wget: wget :: (MonadIO m, MonadAttempt m) => String -> [(String, String)] -> [(String, String)] -> m String

Files

Network/HTTP/Wget.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable #-} --------------------------------------------------------- -- | -- Module        : Network.HTTP.Wget@@ -20,13 +21,21 @@ import System.IO import Numeric (showHex) import Data.List (intercalate)+import Control.Monad.Trans+import Control.Monad.Attempt.Class+import Control.Exception+import Data.Generics +newtype WgetError = WgetError String+    deriving (Show, Typeable)+instance Exception WgetError+ -- | Get a response from the given URL with the given parameters.-wget :: Monad m+wget :: (MonadIO m, MonadAttempt m)      => String -- ^ The URL.      -> [(String, String)] -- ^ Get parameters.      -> [(String, String)] -- ^ Post parameters. If empty, this will be a get request.-     -> IO (m String) -- ^ The response body.+     -> m String -- ^ The response body. wget url get post = do     let getSepChar :: Char         getSepChar = if '?' `elem` url then '&' else '?'@@ -36,13 +45,14 @@         post' = if null post                     then []                     else ["--post-data", urlEncodePairs post]-    (Nothing, Just hout, Just herr, phandle) <- createProcess $ (proc "wget"+    (Nothing, Just hout, Just herr, phandle) <- liftIO $+        createProcess $ (proc "wget"             ((url ++ get') : post' ++ ["-O", "-"])         ) { std_out = CreatePipe, std_err = CreatePipe }-    exitCode <- waitForProcess phandle+    exitCode <- liftIO $ waitForProcess phandle     case exitCode of-        ExitSuccess -> hGetContents hout >>= return . return-        _ -> hGetContents herr >>= return . fail+        ExitSuccess -> liftIO $ hGetContents hout+        _ -> liftIO (hGetContents herr) >>= failure . WgetError  urlEncodePairs :: [(String, String)] -> String urlEncodePairs = intercalate "&" . map urlEncodePair
http-wget.cabal view
@@ -1,5 +1,5 @@ name:            http-wget-version:         0.0.0+version:         0.2.0 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -17,6 +17,10 @@ homepage:        http://github.com/snoyberg/http-wget/tree/master  library-    build-depends:   base, process+    build-depends:   base >= 4 && < 5,+                     process,+                     attempt,+                     transformers >= 0.1.4.0,+                     syb     exposed-modules: Network.HTTP.Wget     ghc-options:     -Wall