AUI Framework
master
Cross-platform module-based framework for developing C++20 desktop applications
|
Easy curl instance. More...
Classes | |
class | Builder |
struct | ErrorDescription |
class | Exception |
struct | Response |
Response struct for Builder::runBlocking() and Builder::runAsync() More... | |
Public Types | |
enum class | Http { VERSION_NONE , VERSION_1_0 , VERSION_1_1 , VERSION_2_0 , VERSION_2TLS , VERSION_2_PRIOR_KNOWLEDGE , VERSION_3 = 30 , VERSION_LAST } |
enum class | ResponseCode { HTTP_100_CONTINUE = 100 , HTTP_101_SWITCHING_PROTOCOL = 101 , HTTP_102_PROCESSING = 102 , HTTP_103_EARLY_HINTS = 103 , HTTP_200_OK = 200 , HTTP_201_CREATED = 201 , HTTP_202_ACCEPTED = 202 , HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203 , HTTP_204_NO_CONTENT = 204 , HTTP_205_RESET_CONTENT = 205 , HTTP_206_PARTIAL_CONTENT = 206 , HTTP_300_MULTIPLE_CHOICE = 300 , HTTP_301_MOVED_PERMANENTLY = 301 , HTTP_302_FOUND = 302 , HTTP_303_SEE_OTHER = 303 , HTTP_304_NOT_MODIFIED = 304 , HTTP_305_USE_PROXY = 305 , HTTP_306_SWITCH_PROXY = 306 , HTTP_307_TEMPORARY_REDIRECT = 307 , HTTP_308_PERMANENT_REDIRECT = 308 , HTTP_400_BAD_REQUEST = 400 , HTTP_401_UNAUTHORIZED = 401 , HTTP_402_PAYMENT_REQUIRED = 402 , HTTP_403_FORBIDDEN = 403 , HTTP_404_NOT_FOUND = 404 , HTTP_405_METHOD_NOT_ALLOWED = 405 , HTTP_406_NOT_ACCEPTABLE = 406 , HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407 , HTTP_408_REQUEST_TIMEOUT = 408 , HTTP_409_CONFLICT = 409 , HTTP_410_GONE = 410 , HTTP_411_LENGTH_REQUIRED = 411 , HTTP_412_PRECONDITION_FAILED = 412 , HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413 , HTTP_414_REQUEST_URI_TOO_LONG = 414 , HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415 , HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416 , HTTP_417_EXPECTATION_FAILED = 417 , HTTP_500_INTERNAL_SERVER_ERROR = 500 , HTTP_501_NOT_IMPLEMENTED = 501 , HTTP_502_BAD_GATEWAY = 502 , HTTP_503_SERVICE_UNAVAILABLE = 503 , HTTP_504_GATEWAY_TIMEOUT = 504 , HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505 } |
enum class | Method { HTTP_GET , HTTP_POST , HTTP_PUT , HTTP_DELETE } |
using | WriteCallback = std::function< size_t(AByteBufferView data)> |
A read callback. More... | |
using | ReadCallback = std::function< std::size_t(char *dst, size_t maxLen)> |
A read callback. More... | |
using | HeaderCallback = std::function< void(AByteBufferView)> |
using | ErrorCallback = std::function< void(const ErrorDescription &description)> |
Public Member Functions | |
ACurl (Builder &builder) | |
ACurl (Builder &&builder) noexcept | |
ACurl (ACurl &&o) noexcept | |
ACurl & | operator= (Builder &&o) noexcept |
ACurl & | operator= (ACurl &&o) noexcept |
int64_t | getContentLength () const |
int64_t | getNumberOfBytesDownloaded () const |
AString | getContentType () const |
void | run () |
virtual void | close () |
Breaks curl loop in the run() method, closing underlying curl connection. More... | |
void * | handle () const noexcept |
ResponseCode | getResponseCode () const |
AString | getErrorString () const noexcept |
Public Member Functions inherited from AObject | |
_< AObject > | sharedPtr () |
_weak< AObject > | weakPtr () |
void | clearSignals () noexcept |
template<AAnySignal Signal, ACompatibleSlotFor< Signal > Function> | |
void | connect (Signal &signal, Function &&function) |
void | setSignalsEnabled (bool enabled) |
bool | isSignalsEnabled () const noexcept |
template<ASignalInvokable T> | |
void | operator^ (T &&t) |
_< AAbstractThread > | getThread () const |
bool | isSlotsCallsOnlyOnMyThread () const noexcept |
void | setSlotsCallsOnlyOnMyThread (bool slotsCallsOnlyOnMyThread) |
Public Member Functions inherited from aui::noncopyable | |
noncopyable (const noncopyable &)=delete | |
noncopyable & | operator= (const noncopyable &)=delete |
Signals and public fields | |
emits< ErrorDescription > | fail |
Emitted on network error. More... | |
emits | success |
Emitted on success. More... | |
emits | closeRequested |
Friends | |
class | ACurlMulti |
Additional Inherited Members | |
Static Public Member Functions inherited from AObject | |
static void | disconnect () |
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function> | |
static void | connect (Signal &signal, Object *object, Function &&function) |
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function> | |
static void | connect (Signal &signal, Object &object, Function &&function) |
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function> | |
static void | connect (Signal &signal, _< Object > object, Function &&function) |
static void | moveToThread (aui::no_escape< AObject > object, _< AAbstractThread > thread) |
Protected Member Functions inherited from AObject | |
void | setThread (_< AAbstractThread > thread) |
Set thread of the object. | |
using ACurl::ReadCallback = std::function<std::size_t(char* dst, size_t maxLen)> |
A read callback.
dst | destination buffer you should write to. |
maxLen | destination buffer size aka max length. |
Unlike regular streams, blocking is not allowed. To indicate the data unavailability, return zero. To indicate end of file, throw an AEOFException.
using ACurl::WriteCallback = std::function<size_t(AByteBufferView data)> |
A read callback.
data | received data |
Unlike regular streams, blocking is not allowed. To indicate buffer overflow, return zero. To indicate end of file, throw an AEOFException.
|
virtual |
Breaks curl loop in the run() method, closing underlying curl connection.
curl does not have a function which immediately stops the transfer (see https://curl.se/docs/faq.html#How_do_I_stop_an_ongoing_transfe). The stop functionality is handled in ACurl by returning error code on all callbacks. close() function is non-blocking, and some time would be taken until the run() method finally returns.
After calling close() method, none of the result signals (like fail, success) will be called.
close() is non-blocking function.
close() is thread-safe.
Reimplemented in AWebsocket.
emits<ErrorDescription> ACurl::fail |
Emitted on network error.
getResponseCode()
function. emits ACurl::success |
Emitted on success.
getResponseCode()
function. #include <AUI/Curl/ACurl.h>