AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ACurl::Builder Class Reference

Public Member Functions

 Builder (AString url)
 
 Builder (const Builder &)=delete
 
BuilderwithWriteCallback (WriteCallback callback)
 Called on server -> client data received (download).
 
BuilderwithMultipart (const AFormMultipart &multipart)
 Add multipart data.
 
BuilderwithBody (ReadCallback callback)
 Called on client -> server data requested (upload).
 
BuilderwithInputStream (_< IInputStream > inputStream)
 Called on client -> server data requested (upload).
 
BuilderwithTimeout (std::chrono::seconds timeout)
 Specifies acceptable response time.
 
BuilderwithBody (std::string contents)
 Like withBody with callback, but wrapped with string.
 
BuilderwithHeaderCallback (HeaderCallback headerCallback)
 Called on header received.
 
BuilderwithErrorCallback (ErrorCallback callback)
 
BuilderwithDestinationBuffer (aui::constraint::avoid_copy< AByteBuffer > dst)
 
BuilderwithOutputStream (_< IOutputStream > dst)
 
BuilderthrowExceptionOnError (bool throwExceptionOnError) noexcept
 
BuilderwithRanges (size_t begin, size_t end)
 Sets: Accept-Ranges: begin-end (download part of the file)
 
BuilderwithRanges (size_t begin)
 Sets: Accept-Ranges: begin-end (download part of the file)
 
BuilderwithLowSpeedLimit (size_t speed)
 Set the average transfer speed in bytes per that the transfer should be below during 'low speed time' seconds to consider it to be too slow and abort.
 
BuilderwithLowSpeedTime (std::chrono::seconds duration)
 Duration that the transfer speed should be below the 'low speed limit' to consider it to be too slow and abort.
 
BuilderwithHttpVersion (Http version)
 
BuilderwithUpload (bool upload)
 
BuilderwithCustomRequest (const AString &v)
 
BuilderwithOnSuccess (std::function< void(ACurl &)> onSuccess)
 
template<aui::invocable OnSuccess>
BuilderwithOnSuccess (OnSuccess &&onSuccess)
 
BuilderwithMethod (Method method) noexcept
 Sets HTTP method to the query.
 
BuilderwithParams (const AVector< std::pair< AString, AString > > &params)
 Sets HTTP params to the query.
 
BuilderwithParams (AString params) noexcept
 Sets HTTP params to the query.
 
BuilderwithHeaders (AVector< AString > headers)
 
_unique< IInputStreamtoInputStream ()
 Makes input stream from curl builder.
 
Response runBlocking ()
 Constructs ACurl object and performs curl request in blocking mode. Use toFuture() instead if possible.
 
AFuture< ResponserunAsync ()
 Constructs ACurl object and performs curl request in global ACurlMulti.
 
AFuture< ResponserunAsync (ACurlMulti &curlMulti)
 Constructs ACurl object and performs curl request in specified ACurlMulti.
 

Member Function Documentation

◆ runAsync() [1/2]

AFuture< ACurl::Response > ACurl::Builder::runAsync ( )

Constructs ACurl object and performs curl request in global ACurlMulti.

Returns
Response future.

◆ runAsync() [2/2]

AFuture< ACurl::Response > ACurl::Builder::runAsync ( ACurlMulti & curlMulti)

Constructs ACurl object and performs curl request in specified ACurlMulti.

Returns
Response future.

◆ runBlocking()

ACurl::Response ACurl::Builder::runBlocking ( )

Constructs ACurl object and performs curl request in blocking mode. Use toFuture() instead if possible.

Exceptions
AIOException

◆ toInputStream()

_unique< IInputStream > ACurl::Builder::toInputStream ( )

Makes input stream from curl builder.

Note
creates async task where curl's loop lives in.
Exceptions
AIOException
Returns
input stream

◆ withBody()

Builder & ACurl::Builder::withBody ( ReadCallback callback)
inline

Called on client -> server data requested (upload).

Parameters
callbackcallback to call.
Returns
this

◆ withErrorCallback()

Builder & ACurl::Builder::withErrorCallback ( ErrorCallback callback)
inline
Note
Also disables throwing exception on error

◆ withHeaderCallback()

Builder & ACurl::Builder::withHeaderCallback ( HeaderCallback headerCallback)
inline

Called on header received.

Parameters
headerCallbackcallback to call.
Returns
this

◆ withInputStream()

Builder & ACurl::Builder::withInputStream ( _< IInputStream > inputStream)
inline

Called on client -> server data requested (upload).

Parameters
inputStreaminput stream to get data to upload from.
Returns
this

◆ withLowSpeedLimit()

ACurl::Builder & ACurl::Builder::withLowSpeedLimit ( size_t speed)

Set the average transfer speed in bytes per that the transfer should be below during 'low speed time' seconds to consider it to be too slow and abort.

Parameters
speedthreshold speed (bytes per second).

◆ withLowSpeedTime()

ACurl::Builder & ACurl::Builder::withLowSpeedTime ( std::chrono::seconds duration)

Duration that the transfer speed should be below the 'low speed limit' to consider it to be too slow and abort.

Parameters
durationduration

◆ withMethod()

Builder & ACurl::Builder::withMethod ( Method method)
inlinenoexcept

Sets HTTP method to the query.

GET is by default.

◆ withMultipart()

Builder & ACurl::Builder::withMultipart ( const AFormMultipart & multipart)
inline

Add multipart data.

This function implies adding Content-Type: multipart and it's boundaries, setting withBody with multipart data.

◆ withParams() [1/2]

Builder & ACurl::Builder::withParams ( AString params)
inlinenoexcept

Sets HTTP params to the query.

In GET, the params are encoded and appended to the url.

In POST, this value is used instead of readCallback (withBody).

◆ withParams() [2/2]

ACurl::Builder & ACurl::Builder::withParams ( const AVector< std::pair< AString, AString > > & params)

Sets HTTP params to the query.

Parameters
paramsparams map in key,value pairs.

In GET, the params are encoded and appended to the url.

In POST, this value is used instead of readCallback (withBody).

◆ withRanges() [1/2]

Builder & ACurl::Builder::withRanges ( size_t begin)
inline

Sets: Accept-Ranges: begin-end (download part of the file)

Parameters
beginstart index of the part
Returns
this

◆ withRanges() [2/2]

ACurl::Builder & ACurl::Builder::withRanges ( size_t begin,
size_t end )

Sets: Accept-Ranges: begin-end (download part of the file)

Parameters
beginstart index of the part
endend index of the part.
Returns
this

◆ withTimeout()

ACurl::Builder & ACurl::Builder::withTimeout ( std::chrono::seconds timeout)

Specifies acceptable response time.

Returns
this

◆ withWriteCallback()

Builder & ACurl::Builder::withWriteCallback ( WriteCallback callback)
inline

Called on server -> client data received (download).

Parameters
callbackcallback to call.
Returns
this
See also
withDestinationBuffer

The documentation for this class was generated from the following files: