23 return "/" + _request;
26 return "/" + _request +
"?" +
argsToUrl();
45 auto it = _args.constBegin();
46 while (it != _args.constEnd()) {
48 args.append(QString(
"%0=%1").arg(it.key(), it->toString()).toUtf8());
50 args.append(QString(
"&%0=%1").arg(it.key(), it->toString()).toUtf8());
59 QSharedPointer<QHttpMultiPart> multiPart = QSharedPointer<QHttpMultiPart>::create(QHttpMultiPart::FormDataType);
61 auto it = _args.constBegin();
62 while (it != _args.constEnd()) {
64 auto && value = it.value();
67 auto metaData = it.key().split(
":");
69 if (metaData.size() == 3) {
70 const auto fileName = metaData[1];
71 const auto fileType = metaData[2];
73 part.setHeader(QNetworkRequest::ContentDispositionHeader,
74 "form-data; name=\"" + fileType +
"\"; filename=\"" + fileName +
"\"");
76 part.setBody(value.toByteArray());
78 qWarning() <<
"the file arguments must be like _file_:fileName:fileType";
83 part.setHeader(QNetworkRequest::ContentDispositionHeader,
"form-data; name=\"" + it.key() +
"\"");
84 part.setBody(value.toByteArray());
86 multiPart->append(part);
99 _request = newRequest;
QString argsToUrl() const
argsToUrl This method converts the arguments to a URL string.
@ Get
general ger request, all request data sent as a url line
virtual QString makeUpload() const
makeUpload This method prepare data to upload;
void setRequest(const QString &newRequest)
setRequest sets custom requests commnad
const QMap< QString, QVariant > & args() const
args This method returns a current list of arguments
const QString & request() const
request return current requests commnad.
void setArgs(const QMap< QString, QVariant > &newArgs)
setArgs For the some requests list of arguments posible to build only after constructor.
void addArg(const QString &key, const QVariant &val)
addArg This method push new arg, to arguments list
virtual RequestMethod method() const =0
method returns method of the request.
QSharedPointer< QHttpMultiPart > argsToMultipartFormData() const
argsToMultipartFormData This method generates multipart/form-data request data.
#define REQUEST_UPLOAD_FILE_KEY