Curl

Wrapper to provide a better interface to libcurl than using the plain C API. It is recommended to use the HTTP/FTP etc. structs instead unless raw access to libcurl is needed.

Warning: This struct uses interior pointers for callbacks. Only allocate it on the stack if you never move or copy it. This also means passing by reference when passing Curl to other functions. Otherwise always allocate on the heap.

struct Curl {}

Members

Functions

clear
void clear(CurlOption option)

Clear a pointer option.

clearIfSupported
void clearIfSupported(CurlOption option)

Clear a pointer option. Does not raise an exception if the underlying libcurl does not support the option. Use sparingly.

dup
Curl dup()

Duplicate this handle.

getTiming
CurlCode getTiming(CurlInfo timing, double val)

Get the various timings like name lookup time, total time, connect time etc. The timed category is passed through the timing parameter while the timing value is stored at val. The value is usable only if res is equal to etc.c.curl.CurlError.ok.

initialize
void initialize()

Initialize the instance by creating a working curl handle.

pause
void pause(bool sendingPaused, bool receivingPaused)

Pausing and continuing transfers.

perform
CurlCode perform(ThrowOnError throwOnError)

perform the curl request by doing the HTTP,FTP etc. as it has been setup beforehand.

set
void set(CurlOption option, const(char)[] value)

Set a string curl option.

set
void set(CurlOption option, long value)

Set a long curl option.

set
void set(CurlOption option, void* value)

Set a void* curl option.

shutdown
void shutdown()

Stop and invalidate this curl instance. Warning: Do not call this from inside a callback handler e.g. onReceive.

Properties

onProgress
int delegate(size_t dlTotal, size_t dlNow, size_t ulTotal, size_t ulNow) onProgress [@property setter]

The event handler that gets called to inform of upload/download progress.

onReceive
size_t delegate(InData) onReceive [@property setter]

The event handler that receives incoming data.

onReceiveHeader
void delegate(in char[]) onReceiveHeader [@property setter]

The event handler that receives incoming headers for protocols that uses headers.

onSeek
CurlSeek delegate(long, CurlSeekPos) onSeek [@property setter]

The event handler that gets called when the curl backend needs to seek the data to be sent.

onSend
size_t delegate(OutData) onSend [@property setter]

The event handler that gets called when data is needed for sending.

onSocketOption
int delegate(curl_socket_t, CurlSockType) onSocketOption [@property setter]

The event handler that gets called when the net socket has been created but a connect() call has not yet been done. This makes it possible to set misc. socket options.

stopped
bool stopped [@property getter]

Meta