minicurl-0: Minimal bindings to libcurl
Safe HaskellSafe-Inferred
LanguageHaskell2010

MiniCurl

Synopsis

Documentation

data CURL Source #

Curl handle.

withLibcurl :: IO r -> IO r Source #

(Globally) initialize libcurl.

Wrap your main in it:

main :: IO ()
main = withLibcurl $ do
    ...

withCurl :: (CURL -> IO r) -> IO r Source #

Create curl handle.

Note: you can reuse CURL handle for multiple requests.

curlPerform Source #

Arguments

:: CURL

CURL handle

-> String

URL

-> Int

Expected size of the output.

-> IO ByteString 

Perform request.

The resulting ByteString will be exactly of the size specified by size argument. If response is smaller, the rest will be zeros; if larger the response will be truncated (not read further)! It's your job to verify that transport was successful, e.g. if you know the expected hash of the download.

curlPerform is thread-safe (underlying handle in CURL is wrapped in MVar).

curlResponseCode :: CURL -> IO Int Source #

Get (last) response code.