qTbot 0.2.106.03782ba
qTbot is base back end library for your c++ Qt projects.
irequest.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2023-2024 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8
9#ifndef IREQUEST_H
10#define IREQUEST_H
11
12#include "qTbot/global.h"
13
14#include <QByteArray>
15#include <QMap>
16#include <QString>
17#include <QHttpMultiPart>
18
19#define REQUEST_UPLOAD_FILE_KEY "_file_"
20
21namespace qTbot {
22
26typedef QHash<QString, QSharedPointer<QJsonObject>> ExtraJsonObjects;
27
33{
34public:
35 iRequest();
36
46 Upload
47 };
48
53 NoPriority = 0,
54 LowPriority = 1,
55 NormalPriority = 2,
56 HighPriority = 3,
57 UngeredPriority = 4,
58
59 MaxPriorityValue = 0xff
60 };
61
66 virtual QString makeUpload() const;
67
72 virtual QString baseAddress() const = 0;
73
78 virtual RequestMethod method() const = 0;
79
84 const QString& request() const;
85
90 void setRequest(const QString &newRequest);
91
96 const QMap<QString, QVariant> &args() const;
97
103 void addArg(const QString& key, const QVariant& val);
104
109 void setArgs(const QMap<QString, QVariant> &newArgs);
110
116 QString argsToUrl() const;
117
124 QSharedPointer<QHttpMultiPart> argsToMultipartFormData() const;
125
130 RequestPriority priority() const;
131
132 void setPriority(RequestPriority newPriority);
133
134private:
135 QString _request;
136 QMap<QString, QVariant> _args;
137 RequestPriority _priority = RequestPriority::NormalPriority;
138
139};
140
141}
142#endif // IREQUEST_H
The iRequest class Is main interface for all custom requests.
Definition irequest.h:33
RequestMethod
RequestMethod Tgis islist of supported requests types of the requests.
Definition irequest.h:40
@ Post
general post request
Definition irequest.h:44
@ Get
general ger request, all request data sent as a url line
Definition irequest.h:42
virtual QString baseAddress() const =0
baseAddress This method return base domain of remote server.
virtual RequestMethod method() const =0
method returns method of the request.
RequestPriority
The RequestPriority enum.
Definition irequest.h:52
#define QTBOT_EXPORT
Definition global.h:18
QHash< QString, QSharedPointer< QJsonObject > > ExtraJsonObjects
ExtraJsonObjects hash map of the extra objects of the message.
Definition irequest.h:26