|
RestLink 2.2.0
Powerfull Rest Client for Qt
|
Represents the body of an HTTP request. More...
#include <body.h>
Public Types | |
| enum class | Type { PlainText , JsonData , RawData , IODevice , HttpMultiPart , Unknown = -1 } |
| Describes the type of content contained in the request body. More... | |
Public Member Functions | |
| Body () | |
| Constructs an empty Body. | |
| Body (const char *data, int size=-1, const QByteArray &contentType=QByteArray()) | |
| Constructs a Body from a C-style byte array. | |
| Body (const QByteArray &data, const QByteArray &contentType=QByteArray()) | |
| Constructs a Body from a QByteArray. | |
| Body (const QString &text, const QByteArray &contentType=QByteArray()) | |
| Constructs a Body from a QString. | |
| Body (const QJsonObject &object) | |
| Constructs a Body from a QJsonObject. | |
| Body (const QJsonArray &array) | |
| Constructs a Body from a QJsonArray. | |
| Body (const QJsonDocument &doc) | |
| Constructs a Body from a QJsonDocument. | |
| Body (const File &file) | |
| Constructs a Body from a RestLink::File. | |
| Body (QFile *file) | |
| Constructs a Body from a QFile pointer. | |
| Body (QIODevice *device, const QByteArray &contentType=QByteArray()) | |
| Constructs a Body from a QIODevice. | |
| Body (QIODevice *device, qint64 size, const QByteArray &contentType=QByteArray()) | |
| Constructs a Body from a QIODevice with a known content length. | |
| Body (QHttpMultiPart *multiPart) | |
| Constructs a Body from a QHttpMultiPart. | |
| Body (const Body &other) | |
| Copy constructor. | |
| Body (Body &&other) | |
| Move constructor. | |
| ~Body () | |
| Destructor. | |
| Body & | operator= (const Body &other) |
| Copy assignment operator. | |
| Body & | operator= (Body &&other) |
| Move assignment operator. | |
| bool | hasPlainText () const |
| QByteArray | toByteArray () const |
| QString | toString () const |
| bool | hasJsonObject () const |
| QJsonObject | jsonObject () const |
| bool | hasJsonArray () const |
| QJsonArray | jsonArray () const |
| bool | isDevice () const |
| QIODevice * | device () const |
| bool | isMultiPart () const |
| QHttpMultiPart * | multiPart () const |
| QVariant | object () const |
| Type | objectType () const |
| QString | contentType () const |
| Returns the content type as a MIME string. | |
| qint64 | contentLength () const |
| Returns the length of the content, if known. | |
| HeaderList | headers () const |
| Returns the list of headers associated with the Body. | |
Represents the body of an HTTP request.
The Body class provides an abstraction over various types of request payloads, including plain text, JSON data, binary data, and streaming via QIODevice or multipart form data. It allows convenient construction and inspection of content and its metadata such as content type and length.
|
strong |
Describes the type of content contained in the request body.
This enum helps identify how the request body should be processed or interpreted.
| RestLink::Body::Body | ( | ) |
Constructs an empty Body.
| RestLink::Body::Body | ( | const char * | data, |
| int | size = -1, |
||
| const QByteArray & | contentType = QByteArray() |
||
| ) |
Constructs a Body from a C-style byte array.
| data | Pointer to the data. |
| size | Number of bytes (or -1 for null-terminated). |
| contentType | MIME type of the content. |
| RestLink::Body::Body | ( | const QByteArray & | data, |
| const QByteArray & | contentType = QByteArray() |
||
| ) |
Constructs a Body from a QByteArray.
| data | The content as a QByteArray. |
| contentType | MIME type of the content. |
| RestLink::Body::Body | ( | const QString & | text, |
| const QByteArray & | contentType = QByteArray() |
||
| ) |
Constructs a Body from a QString.
| text | The string content. |
| contentType | MIME type of the content. |
| RestLink::Body::Body | ( | const QJsonObject & | object | ) |
Constructs a Body from a QJsonObject.
| RestLink::Body::Body | ( | const QJsonArray & | array | ) |
Constructs a Body from a QJsonArray.
| RestLink::Body::Body | ( | const QJsonDocument & | doc | ) |
Constructs a Body from a QJsonDocument.
| RestLink::Body::Body | ( | const File & | file | ) |
Constructs a Body from a RestLink::File.
| RestLink::Body::Body | ( | QFile * | file | ) |
Constructs a Body from a QFile pointer.
| RestLink::Body::Body | ( | QIODevice * | device, |
| const QByteArray & | contentType = QByteArray() |
||
| ) |
Constructs a Body from a QIODevice.
| device | The device supplying the data. |
| contentType | MIME type of the content. |
| RestLink::Body::Body | ( | QIODevice * | device, |
| qint64 | size, | ||
| const QByteArray & | contentType = QByteArray() |
||
| ) |
Constructs a Body from a QIODevice with a known content length.
| device | The device supplying the data. |
| size | Length of the content in bytes. |
| contentType | MIME type of the content. |
| RestLink::Body::Body | ( | QHttpMultiPart * | multiPart | ) |
Constructs a Body from a QHttpMultiPart.
|
default |
Copy constructor.
|
default |
Move constructor.
|
default |
Destructor.
| bool RestLink::Body::hasPlainText | ( | ) | const |
| QByteArray RestLink::Body::toByteArray | ( | ) | const |
| QString RestLink::Body::toString | ( | ) | const |
| bool RestLink::Body::hasJsonObject | ( | ) | const |
| QJsonObject RestLink::Body::jsonObject | ( | ) | const |
| bool RestLink::Body::hasJsonArray | ( | ) | const |
| QJsonArray RestLink::Body::jsonArray | ( | ) | const |
| bool RestLink::Body::isDevice | ( | ) | const |
| QIODevice * RestLink::Body::device | ( | ) | const |
| bool RestLink::Body::isMultiPart | ( | ) | const |
| QHttpMultiPart * RestLink::Body::multiPart | ( | ) | const |
| QVariant RestLink::Body::object | ( | ) | const |
| Body::Type RestLink::Body::objectType | ( | ) | const |
| QString RestLink::Body::contentType | ( | ) | const |
Returns the content type as a MIME string.
| qint64 RestLink::Body::contentLength | ( | ) | const |
Returns the length of the content, if known.
| HeaderList RestLink::Body::headers | ( | ) | const |
Returns the list of headers associated with the Body.
headers like Content-Type and Content-Length are added automatically.