mirror of
https://github.com/QuasarApp/qthttpserver.git
synced 2025-04-27 02:44:31 +00:00
QHttpServerResponse: Use rvalue more
Change-Id: I442245dc800a545142f3f28ea51a4465d6eaff84 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
055d36692b
commit
03f911fd0a
@ -56,7 +56,7 @@ QHttpServerResponse::QHttpServerResponse(const QHttpServerResponse::StatusCode s
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(const char *data)
|
||||
: QHttpServerResponse(QByteArray(data))
|
||||
: QHttpServerResponse(QByteArray::fromRawData(data, qstrlen(data)))
|
||||
{
|
||||
}
|
||||
|
||||
@ -70,6 +70,13 @@ QHttpServerResponse::QHttpServerResponse(const QByteArray &data)
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(QByteArray &&data)
|
||||
: QHttpServerResponse(
|
||||
QMimeDatabase().mimeTypeForData(data).name().toLocal8Bit(),
|
||||
std::move(data))
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(const QJsonObject &data)
|
||||
: QHttpServerResponse(mimeApplicationJson,
|
||||
QJsonDocument(data).toJson(QJsonDocument::Compact))
|
||||
@ -89,6 +96,31 @@ QHttpServerResponse::QHttpServerResponse(const QByteArray &mimeType,
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(QByteArray &&mimeType,
|
||||
const QByteArray &data,
|
||||
const StatusCode status)
|
||||
: QHttpServerResponse(
|
||||
new QHttpServerResponsePrivate{std::move(mimeType), data, status})
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(const QByteArray &mimeType,
|
||||
QByteArray &&data,
|
||||
const StatusCode status)
|
||||
: QHttpServerResponse(
|
||||
new QHttpServerResponsePrivate{mimeType, std::move(data), status})
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::QHttpServerResponse(QByteArray &&mimeType,
|
||||
QByteArray &&data,
|
||||
const StatusCode status)
|
||||
: QHttpServerResponse(
|
||||
new QHttpServerResponsePrivate{std::move(mimeType), std::move(data),
|
||||
status})
|
||||
{
|
||||
}
|
||||
|
||||
QHttpServerResponse::~QHttpServerResponse()
|
||||
{
|
||||
}
|
||||
|
@ -54,14 +54,30 @@ public:
|
||||
QHttpServerResponse& operator=(QHttpServerResponse &&other) = delete;
|
||||
|
||||
QHttpServerResponse(const StatusCode statusCode);
|
||||
|
||||
QHttpServerResponse(const char *data);
|
||||
|
||||
QHttpServerResponse(const QString &data);
|
||||
|
||||
explicit QHttpServerResponse(const QByteArray &data);
|
||||
explicit QHttpServerResponse(QByteArray &&data);
|
||||
|
||||
QHttpServerResponse(const QJsonObject &data);
|
||||
QHttpServerResponse(const QJsonArray &data);
|
||||
|
||||
QHttpServerResponse(const QByteArray &mimeType,
|
||||
const QByteArray &data,
|
||||
const StatusCode status = StatusCode::Ok);
|
||||
QHttpServerResponse(QByteArray &&mimeType,
|
||||
const QByteArray &data,
|
||||
const StatusCode status = StatusCode::Ok);
|
||||
QHttpServerResponse(const QByteArray &mimeType,
|
||||
QByteArray &&data,
|
||||
const StatusCode status = StatusCode::Ok);
|
||||
QHttpServerResponse(QByteArray &&mimeType,
|
||||
QByteArray &&data,
|
||||
const StatusCode status = StatusCode::Ok);
|
||||
|
||||
virtual ~QHttpServerResponse();
|
||||
static QHttpServerResponse fromFile(const QString &fileName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user