ACurl#
Easy curl instance.
Header: | #include <AUI/Curl/ACurl.h> |
CMake: | aui_link(my_target PUBLIC aui::curl) |
Detailed Description#
ACurl::Builder is used to construct ACurl.
Analogous to Qt's QNetworkRequest.
Public Types#
Http#
enum class ACurl::Http
Constant | Description |
---|---|
Http::VERSION_NONE
|
|
Http::VERSION_1_0
|
|
Http::VERSION_1_1
|
|
Http::VERSION_2_0
|
|
Http::VERSION_2TLS
|
|
Http::VERSION_2_PRIOR_KNOWLEDGE
|
|
Http::VERSION_3
|
|
Http::VERSION_LAST
|
ResponseCode#
enum class ACurl::ResponseCode
Constant | Description |
---|---|
ResponseCode::HTTP_100_CONTINUE
|
|
ResponseCode::HTTP_101_SWITCHING_PROTOCOL
|
|
ResponseCode::HTTP_102_PROCESSING
|
|
ResponseCode::HTTP_103_EARLY_HINTS
|
|
ResponseCode::HTTP_200_OK
|
|
ResponseCode::HTTP_201_CREATED
|
|
ResponseCode::HTTP_202_ACCEPTED
|
|
ResponseCode::HTTP_203_NON_AUTHORITATIVE_INFORMATION
|
|
ResponseCode::HTTP_204_NO_CONTENT
|
|
ResponseCode::HTTP_205_RESET_CONTENT
|
|
ResponseCode::HTTP_206_PARTIAL_CONTENT
|
|
ResponseCode::HTTP_300_MULTIPLE_CHOICE
|
|
ResponseCode::HTTP_301_MOVED_PERMANENTLY
|
|
ResponseCode::HTTP_302_FOUND
|
|
ResponseCode::HTTP_303_SEE_OTHER
|
|
ResponseCode::HTTP_304_NOT_MODIFIED
|
|
ResponseCode::HTTP_305_USE_PROXY
|
|
ResponseCode::HTTP_306_SWITCH_PROXY
|
|
ResponseCode::HTTP_307_TEMPORARY_REDIRECT
|
|
ResponseCode::HTTP_308_PERMANENT_REDIRECT
|
|
ResponseCode::HTTP_400_BAD_REQUEST
|
|
ResponseCode::HTTP_401_UNAUTHORIZED
|
|
ResponseCode::HTTP_402_PAYMENT_REQUIRED
|
|
ResponseCode::HTTP_403_FORBIDDEN
|
|
ResponseCode::HTTP_404_NOT_FOUND
|
|
ResponseCode::HTTP_405_METHOD_NOT_ALLOWED
|
|
ResponseCode::HTTP_406_NOT_ACCEPTABLE
|
|
ResponseCode::HTTP_407_PROXY_AUTHENTICATION_REQUIRED
|
|
ResponseCode::HTTP_408_REQUEST_TIMEOUT
|
|
ResponseCode::HTTP_409_CONFLICT
|
|
ResponseCode::HTTP_410_GONE
|
|
ResponseCode::HTTP_411_LENGTH_REQUIRED
|
|
ResponseCode::HTTP_412_PRECONDITION_FAILED
|
|
ResponseCode::HTTP_413_REQUEST_ENTITY_TOO_LARGE
|
|
ResponseCode::HTTP_414_REQUEST_URI_TOO_LONG
|
|
ResponseCode::HTTP_415_UNSUPPORTED_MEDIA_TYPE
|
|
ResponseCode::HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE
|
|
ResponseCode::HTTP_417_EXPECTATION_FAILED
|
|
ResponseCode::HTTP_500_INTERNAL_SERVER_ERROR
|
|
ResponseCode::HTTP_501_NOT_IMPLEMENTED
|
|
ResponseCode::HTTP_502_BAD_GATEWAY
|
|
ResponseCode::HTTP_503_SERVICE_UNAVAILABLE
|
|
ResponseCode::HTTP_504_GATEWAY_TIMEOUT
|
|
ResponseCode::HTTP_505_HTTP_VERSION_NOT_SUPPORTED
|
Method#
enum class ACurl::Method
Constant | Description |
---|---|
Method::HTTP_GET
|
|
Method::HTTP_POST
|
|
Method::HTTP_PUT
|
|
Method::HTTP_DELETE
|
Response#
struct ACurl::Response
Response struct for Builder::runBlocking() and Builder::runAsync()
Field | Description |
---|---|
ResponseCode code
|
|
AString contentType
|
|
AByteBuffer body
|
ErrorDescription#
struct ACurl::ErrorDescription
Empty structure.
Exception#
class ACurl::Exception
Empty structure.
Builder#
class ACurl::Builder
Examples#
examples/app/notes/src/main.cpp
Notes App - Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.
},
/// [scrollarea]
AScrollArea::Builder()
.withContents(
AUI_DECLARATIVE_FOR(note, *mNotes, AVerticalLayout) {
observeChangesForDirty(note);
return notePreview(note) AUI_LET {
connect(it->clicked, [this, note] { mCurrentNote = note; });
it& mCurrentNote > [note](AView& view, const _<Note>& currentNote) {
ALOG_DEBUG(LOG_TAG) << "currentNote == note " << currentNote << " == " << note;
examples/ui/backdrop/src/main.cpp
Backdrop - Backdrop effects demo.
using namespace ass;
static auto headerWithContents(_<AView> content) {
auto result = Stacked {
AScrollArea::Builder().withContents(content).build() AUI_WITH_STYLE {
Expanding(),
Padding { 80_dp, 0, 0 },
} AUI_LET { it->setExtraStylesheet(
AStylesheet {
{
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
},
});
connect(mEditorMode, [this] {
setContents(Vertical::Expanding {
AScrollArea::Builder().withContents(Centered {
Vertical::Expanding {
Horizontal {
profilePhoto(mContact),
Centered::Expanding {
presentation(mContact->displayName) AUI_WITH_STYLE { FontSize { 12_pt } },
examples/7guis/crud/src/main.cpp
7GUIs CRUD - Create/Read/Update/Delete example.
Label { "Filter prefix:" },
_new<ATextField>() AUI_WITH_STYLE { Expanding(1, 0) } && mFilterPrefix,
},
AScrollArea::Builder().withExpanding().withContents(
AUI_DECLARATIVE_FOR(i, *mUsers | FILTER_VIEW, AVerticalLayout) {
auto view = _new<ALabel>();
view & i->displayName;
connect(mSelectedUser, view, [this, &view = *view, i] {
view.setAssName("selected", mSelectedUser == i);
});
examples/7guis/cells/src/main.cpp
7GUIs Cells - Spreadsheet processor (Excel).
Empty structure.
Public fields and Signals#
ReadCallback#
using ReadCallback
A read callback.
dst destination buffer you should write to. maxLen destination buffer size aka max length. bytes written to the destination buffer. Zero means data unavailability (but the stream may be continued in the future). Unlike regular streams, blocking is not allowed. To indicate the data unavailability, return zero. To indicate end of file, throw an AEOFException.
WriteCallback#
using WriteCallback
A read callback.
data received data bytes written to the destination buffer. Zero means buffer does not have enough space to store supplied data (but the stream may be continued in the future), the supplied data is not discarded and being kept in the curl buffers. Unlike regular streams, blocking is not allowed. To indicate buffer overflow, return zero. To indicate end of file, throw an AEOFException.
WriteCallbackV2#
using WriteCallbackV2
A read callback.
curl curl instance data received data bytes written to the destination buffer. Zero means buffer does not have enough space to store supplied data (but the stream may be continued in the future), the supplied data is not discarded and being kept in the curl buffers. Unlike regular streams, blocking is not allowed. To indicate buffer overflow, return zero. To indicate end of file, throw an AEOFException.
fail#
emits<ErrorDescription> fail
Emitted on network error.
A protocol-level error (like HTTP(S) 404) is not treated as a fail. Check for response code via the
getResponseCode()
function.
success#
emits<> success
Emitted on success.
A protocol-level error (like HTTP(S) 404) is not treated as a fail. Check for response code via the
getResponseCode()
function.
Public Methods#
close#
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.
Examples#
examples/app/fractal/src/JumpToCoordsWindow.cpp
Fractal Example - Fractal viewer application demonstrating usage of custom shaders.
auto dRe = std::stod((*re->text()).toStdString());
auto dIm = -std::stod((*re->text()).toStdString());
auto dScale = std::stod((*re->text()).toStdString());
fractalView->setPlotPositionAndScale(glm::dvec2 { dRe, dIm }, dScale);
close();
} catch (...) {
AMessageBox::show(this, "Error", "Please check your values are valid numbers.");
}
}) AUI_LET { it->setDefault(); },
_new<AButton>("Cancel").connect(&AButton::clicked, me::close),