ezcurl

Friendly wrapper around OCurl
IN THIS PACKAGE
Module type Ezcurl_core . S

Main Signature

type 'a io
val http : ?tries:int -> ?client:t -> ?config:Config.t -> ?range:string -> ?content:[ `String of string | `Write of bytes -> int -> int ] -> ?headers:(string * string) list -> url:string -> meth:meth -> unit -> ( response, Curl.curlCode * string ) result io

General purpose HTTP call via cURL.

  • parameter url

    the URL to query

  • parameter meth

    which method to use (see meth)

  • parameter tries

    how many times to retry in case of CURLE_AGAIN code

  • parameter client

    a client to reuse (instead of allocating a new one)

  • parameter range

    an optional byte range to fetch (either to get large pages by chunks, or to resume an interrupted download).

  • parameter config

    configuration to set

  • parameter content

    the content to send as the query's body, either a `String s to write a single string, or `Write f where f is a callback that is called on a buffer b with len n (as in f b n) and returns how many bytes it wrote in the buffer b starting at index 0 (at most n bytes). It must return 0 when the content is entirely written, and not before.

  • parameter headers

    headers of the query

val get : ?tries:int -> ?client:t -> ?config:Config.t -> ?range:string -> ?headers:(string * string) list -> url:string -> unit -> ( response, Curl.curlCode * string ) result io

Shortcut for http ~meth:GET See http for more info.

val put : ?tries:int -> ?client:t -> ?config:Config.t -> ?headers:(string * string) list -> url:string -> content:[ `String of string | `Write of bytes -> int -> int ] -> unit -> ( response, Curl.curlCode * string ) result io

Shortcut for http ~meth:PUT See http for more info.

val post : ?tries:int -> ?client:t -> ?config:Config.t -> ?headers:(string * string) list -> ?content:[ `String of string | `Write of bytes -> int -> int ] -> params:Curl.curlHTTPPost list -> url:string -> unit -> ( response, Curl.curlCode * string ) result io

Shortcut for http ~meth:(POST params) See http for more info.