curl-1.3.8: Haskell binding to libcurl

Copyright | (c) 2007-2009 Galois Inc
License | BSD3
Maintainer | Sigbjorn Finne <sof@galois.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell98

Network.Curl

Description

A Haskell binding the libcurl library http://curl.haxx.se/, a proven and feature-rich library for interacting with HTTP(S)/FTP servers.

The binding was initially made against version 7.16.2; libcurl does appear to be considerate in not introducing breaking changes wrt older versions. So, unless you're after the latest features (i.e., constructors towards the end the Option type), there's a very good chance your code will work against older installations of libcurl.

Synopsis

- module Network.Curl.Opts
- module Network.Curl.Easy
- module Network.Curl.Post
- module Network.Curl.Info
- module Network.Curl.Types
- module Network.Curl.Code
- withCurlDo :: IO a -> IO a
- setopts :: Curl -> [CurlOption] -> IO ()
- data CurlResponse_ headerTy bodyTy = CurlResponse {
  - respCurlCode :: CurlCode
  - respStatus :: Int
  - respStatusLine :: String
  - respHeaders :: headerTy
  - respBody :: bodyTy
  - respGetInfo :: Info -> IO InfoValue
  }
- type CurlResponse = CurlResponse_ [(String, String)] String
- curlGet :: URLString -> [CurlOption] -> IO ()
- curlGetString :: URLString -> [CurlOption] -> IO (CurlCode, String)
- curlGetResponse :: URLString -> [CurlOption] -> IO CurlResponse
- perform_with_response :: (CurlHeader hdrTy, CurlBuffer bufTy) => Curl -> IO (CurlResponse_ hdrTy bufTy)
- do_curl :: Curl -> URLString -> [CurlOption] -> IO CurlResponse
- curlGetString_ :: CurlBuffer ty => URLString -> [CurlOption] -> IO (CurlCode, ty)
- curlGetResponse_ :: (CurlHeader hdr, CurlBuffer ty) => URLString -> [CurlOption] -> IO (CurlResponse_ hdr ty)
- perform_with_response_ :: (CurlHeader headerTy, CurlBuffer bodyTy) => Curl -> IO (CurlResponse_ headerTy bodyTy)
- do_curl_ :: (CurlHeader headerTy, CurlBuffer bodyTy) => Curl -> URLString -> [CurlOption] -> IO (CurlResponse_ headerTy bodyTy)
- curlHead_ :: CurlHeader headers => URLString -> [CurlOption] -> IO (String, headers)
- curlHead :: URLString -> [CurlOption] -> IO (String, [(String, String)])
- curlMultiPost :: URLString -> [CurlOption] -> [HttpPost] -> IO ()
- curlPost :: URLString -> [String] -> IO ()
- getResponseCode :: Curl -> IO Int
- setDefaultSSLOpts :: Curl -> URLString -> IO ()
- callbackWriter :: (String -> IO ()) -> WriteFunction
- easyWriter :: (String -> IO ()) -> WriteFunction
- ignoreOutput :: WriteFunction
- gatherOutput :: IORef [String] -> WriteFunction
- gatherOutput_ :: (CStringLen -> IO ()) -> WriteFunction
- class CurlBuffer bufferTy where
  - newIncoming :: IO (IO bufferTy, CStringLen -> IO ())
- class CurlHeader headerTy where
  - newIncomingHeader :: IO (IO (String, headerTy), CStringLen -> IO ())
- method_GET :: [CurlOption]
- method_HEAD :: [CurlOption]
- method_POST :: [CurlOption]
- parseStatusNHeaders :: String -> (String, [(String, String)])
- parseHeader :: String -> (String, String)
- concRev :: [a] -> [[a]] -> [a]

# Documentation

module Network.Curl.Opts

module Network.Curl.Easy

module Network.Curl.Post

module Network.Curl.Info

module Network.Curl.Types

module Network.Curl.Code

withCurlDo :: IO a -> IO a #

Should be used once to wrap all uses of libcurl. WARNING: the argument should not return before it is completely done with curl (e.g., no forking or lazy returns)

setopts :: Curl -> [CurlOption] -> IO () #

Set a list of options on a Curl handle.

data CurlResponse_ headerTy bodyTy #

`CurlResponse_` is a record type encoding all the information embodied in a response to your Curl request. Currently only used to gather up the results of doing a GET in `curlGetResponse`.

Constructors

CurlResponse |

Fields

- respCurlCode :: CurlCode
- respStatus :: Int
- respStatusLine :: String
- respHeaders :: headerTy
- respBody :: bodyTy
- respGetInfo :: Info -> IO InfoValue

type CurlResponse = CurlResponse_ [(String, String)] String #

curlGet :: URLString -> [CurlOption] -> IO () #

`curlGet` perform a basic GET, dumping the output on stdout. The list of options are set prior performing the GET request.

curlGetString :: URLString -> [CurlOption] -> IO (CurlCode, String) #

`curlGetString` performs the same request as `curlGet`, but returns the response body as a Haskell string.

curlGetResponse :: URLString -> [CurlOption] -> IO CurlResponse #

Deprecated: Switch to using curlGetResponse_

perform_with_response :: (CurlHeader hdrTy, CurlBuffer bufTy) => Curl -> IO (CurlResponse_ hdrTy bufTy) #

Deprecated: Consider switching to perform_with_response_

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.

do_curl :: Curl -> URLString -> [CurlOption] -> IO CurlResponse #

Deprecated: Consider switching to do_curl_

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`.

curlGetString_ :: CurlBuffer ty => URLString -> [CurlOption] -> IO (CurlCode, ty) #

curlGetResponse_ :: (CurlHeader hdr, CurlBuffer ty) => URLString -> [CurlOption] -> IO (CurlResponse_ hdr ty) #

`curlGetResponse url opts` performs a `GET`, returning all the info it can lay its hands on in the response, a value of type `CurlResponse`. The representation of the body is overloaded

perform_with_response_ :: (CurlHeader headerTy, CurlBuffer bodyTy) => Curl -> IO (CurlResponse_ headerTy bodyTy) #

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. The returned payload is overloaded over the representation of both headers and body via the `CurlResponse_` type.

do_curl_ :: (CurlHeader headerTy, CurlBuffer bodyTy) => Curl -> URLString -> [CurlOption] -> IO (CurlResponse_ headerTy bodyTy) #

curlHead_ :: CurlHeader headers => URLString -> [CurlOption] -> IO (String, headers) #

Get the headers associated with a particular URL. Returns the status line and the key-value pairs for the headers.

curlHead :: URLString -> [CurlOption] -> IO (String, [(String, String)]) #

Get the headers associated with a particular URL. Returns the status line and the key-value pairs for the headers.

curlMultiPost :: URLString -> [CurlOption] -> [HttpPost] -> IO () #

`curlMultiPost` perform a multi-part POST submission.

curlPost :: URLString -> [String] -> IO () #

`curlPost` performs. a common POST operation, namely that of submitting a sequence of name=value pairs.

getResponseCode :: Curl -> IO Int #

setDefaultSSLOpts :: Curl -> URLString -> IO () #

callbackWriter :: (String -> IO ()) -> WriteFunction #

Imports data into the Haskell world and invokes the callback.

easyWriter :: (String -> IO ()) -> WriteFunction #

ignoreOutput :: WriteFunction #

The output of Curl is ignored. This function does not marshall data into Haskell.

gatherOutput :: IORef [String] -> WriteFunction #

Add chunks of data to an IORef as they arrive.

gatherOutput_ :: (CStringLen -> IO ()) -> WriteFunction #

Add chunks of data to an IORef as they arrive.

class CurlBuffer bufferTy where #

The `CurlBuffer` class encodes the representation of response buffers, allowing you to provide your own app-specific buffer reps to be used..or use one of the standard instances (String and ByteStrings.)

Methods

newIncoming :: IO (IO bufferTy, CStringLen -> IO ()) #

#### Instances

Instances details

CurlBuffer ByteString # |
Instance details Defined in Network.Curl Methods newIncoming :: IO (IO ByteString, CStringLen -> IO ()) #
CurlBuffer ByteString # |
Instance details Defined in Network.Curl Methods newIncoming :: IO (IO ByteString, CStringLen -> IO ()) #
CurlBuffer String # |
Instance details Defined in Network.Curl Methods newIncoming :: IO (IO String, CStringLen -> IO ()) #
CurlBuffer [ByteString] # |
Instance details Defined in Network.Curl Methods newIncoming :: IO (IO [ByteString], CStringLen -> IO ()) #

class CurlHeader headerTy where #

The `CurlHeader` class encodes the representation of response headers. Similar to `CurlBuffer`.

Methods

newIncomingHeader :: IO (IO (String, headerTy), CStringLen -> IO ()) #

#### Instances

Instances details

CurlHeader [(String, String)] # |
Instance details Defined in Network.Curl Methods newIncomingHeader :: IO (IO (String, [(String, String)]), CStringLen -> IO ()) #

method_GET :: [CurlOption] #

method_HEAD :: [CurlOption] #

method_POST :: [CurlOption] #

parseStatusNHeaders :: String -> (String, [(String, String)]) #

parseHeader :: String -> (String, String) #

concRev :: [a] -> [[a]] -> [a] #