curl 1.3.1 → 1.3.2
raw patch · 2 files changed
+53/−16 lines, 2 filesdep −haskell98new-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies removed: haskell98
API changes (from Hackage documentation)
+ Network.Curl: concRev :: [a] -> [[a]] -> [a]
+ Network.Curl: do_curl :: Curl -> URLString -> [CurlOption] -> IO CurlResponse
+ Network.Curl: parseStatusNHeaders :: String -> (String, [(String, String)])
+ Network.Curl: perform_with_response :: Curl -> IO CurlResponse
Files
- Network/Curl.hs +50/−13
- curl.cabal +3/−3
Network/Curl.hs view
@@ -39,6 +39,8 @@ , curlGet -- :: URLString -> [CurlOption] -> IO () , curlGetString -- :: URLString -> [CurlOption] -> IO (CurlCode, String) , curlGetResponse -- :: URLString -> [CurlOption] -> IO CurlResponse+ , perform_with_response -- :: Curl -> IO CurlResponse+ , do_curl -- probing for gold.. , curlHead -- :: URLString@@ -63,6 +65,7 @@ , method_HEAD -- :: [CurlOption] , method_POST -- :: [CurlOption] + , parseStatusNHeaders, concRev ) where import Network.Curl.Opts@@ -176,19 +179,53 @@ setopt h (CurlWriteFunction (gatherOutput body_ref)) setopt h (CurlHeaderFunction (gatherOutput hdr_ref)) mapM_ (setopt h) opts- rc <- perform h- bss <- readIORef body_ref- hss <- readIORef hdr_ref- rspCode <- getResponseCode h- let (st,hs) = parseStatusNHeaders (concRev [] hss)- return CurlResponse- { respCurlCode = rc- , respStatus = rspCode- , respStatusLine = st- , respHeaders = hs- , respBody = concRev [] bss- , respGetInfo = getInfo h -- note: we're holding onto the handle here..- }+ -- note that users cannot over-write the body and header handler+ -- which makes sense because otherwise we will return a bogus reposnse.+ perform_with_response h++++-- | Perform the actions already specified on the handle.+-- Collects useful information about the returned message.+-- Note that this function sets the+-- 'CurlWriteFunction' and 'CurlHeaderFunction' options.+perform_with_response :: Curl -> IO CurlResponse+perform_with_response h =+ do body_ref <- newIORef []+ hdr_ref <- newIORef []++ -- Insted of allocating a swparate handler for each+ -- request we could just set this options one and forall+ -- and just clear the IORefs.++ setopt h (CurlWriteFunction (gatherOutput body_ref))+ setopt h (CurlHeaderFunction (gatherOutput hdr_ref))+ rc <- perform h+ bss <- readIORef body_ref+ hss <- readIORef hdr_ref+ rspCode <- getResponseCode h+ let (st,hs) = parseStatusNHeaders (concRev [] hss)+ return CurlResponse+ { respCurlCode = rc+ , respStatus = rspCode+ , respStatusLine = st+ , respHeaders = hs+ , respBody = concRev [] bss+ -- note: we're holding onto the handle here..+ -- note: with this interface this is not neccessary.+ , respGetInfo = getInfo h+ }++-- | Performs a curl request using an exisitng curl handle.+-- The provided URL will overwride any 'CurlURL' options that+-- are provided in the list of options. See also: 'perform_with_response'.+do_curl :: Curl -> URLString -> [CurlOption] -> IO CurlResponse+do_curl h url opts =+ do setDefaultSSLOpts h url+ setopts h opts+ setopt h (CurlURL url)+ perform_with_response h+ -- | Get the headers associated with a particular URL. -- Returns the status line and the key-value pairs for the headers.
curl.cabal view
@@ -1,5 +1,5 @@ name: curl-version: 1.3.1+version: 1.3.2 synopsis: Haskell binding to libcurl description: libcurl is a client-side URL transfer library, supporting FTP, FTPS, HTTP,@@ -35,10 +35,10 @@ Extra-libraries: curl Extensions: CPP, ForeignFunctionInterface- Ghc-options: -Wall -fvia-C -O2+ Ghc-options: -Wall -fvia-C Build-Depends: base if flag(new-base)- Build-depends: base >= 3, containers, haskell98+ Build-depends: base >= 3, containers else Build-depends: base < 3