forked from loafle/openapi-generator-original
[C++] [Qt5] Add request compression and handling identity (#5088)
* Add request and response compression and handling identity * Minor updates for identity and if conditions
This commit is contained in:
parent
0366e946ba
commit
138232d557
@ -96,8 +96,12 @@ void {{prefix}}HttpRequestWorker::setWorkingDirectory(const QString &path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{prefix}}HttpRequestWorker::setCompressionEnabled(bool enable) {
|
void {{prefix}}HttpRequestWorker::setResponseCompressionEnabled(bool enable) {
|
||||||
isCompressionEnabled = enable;
|
isResponseCompressionEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void {{prefix}}HttpRequestWorker::setRequestCompressionEnabled(bool enable) {
|
||||||
|
isRequestCompressionEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
||||||
@ -285,8 +289,12 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
|||||||
if (input->request_body.size() > 0) {
|
if (input->request_body.size() > 0) {
|
||||||
qDebug() << "got a request body";
|
qDebug() << "got a request body";
|
||||||
request_content.clear();
|
request_content.clear();
|
||||||
|
if(!isFormData && (input->var_layout != MULTIPART) && isRequestCompressionEnabled){
|
||||||
|
request_content.append(compress(input->request_body, 7, {{prefix}}CompressionType::Gzip));
|
||||||
|
} else {
|
||||||
request_content.append(input->request_body);
|
request_content.append(input->request_body);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// prepare connection
|
// prepare connection
|
||||||
|
|
||||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
@ -302,14 +310,19 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
|||||||
} else {
|
} else {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
||||||
}
|
}
|
||||||
|
if(isRequestCompressionEnabled){
|
||||||
|
request.setRawHeader("Content-Encoding", "gzip");
|
||||||
|
}
|
||||||
} else if (input->var_layout == URL_ENCODED) {
|
} else if (input->var_layout == URL_ENCODED) {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
} else if (input->var_layout == MULTIPART) {
|
} else if (input->var_layout == MULTIPART) {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isCompressionEnabled){
|
if(isResponseCompressionEnabled){
|
||||||
request.setRawHeader("Accept-Encoding", "deflate, gzip");
|
request.setRawHeader("Accept-Encoding", "gzip");
|
||||||
|
} else {
|
||||||
|
request.setRawHeader("Accept-Encoding", "identity");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->http_method == "GET") {
|
if (input->http_method == "GET") {
|
||||||
@ -391,6 +404,8 @@ void {{prefix}}HttpRequestWorker::process_response(QNetworkReply *reply) {
|
|||||||
auto compressionTypes = encoding.first().split(',', QString::SkipEmptyParts);
|
auto compressionTypes = encoding.first().split(',', QString::SkipEmptyParts);
|
||||||
if(compressionTypes.contains("gzip", Qt::CaseInsensitive) || compressionTypes.contains("deflate", Qt::CaseInsensitive)){
|
if(compressionTypes.contains("gzip", Qt::CaseInsensitive) || compressionTypes.contains("deflate", Qt::CaseInsensitive)){
|
||||||
response = decompress(reply->readAll());
|
response = decompress(reply->readAll());
|
||||||
|
} else if(compressionTypes.contains("identity", Qt::CaseInsensitive)){
|
||||||
|
response = reply->readAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,11 +417,11 @@ void {{prefix}}HttpRequestWorker::process_response(QNetworkReply *reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QByteArray {{prefix}}HttpRequestWorker::decompress(const QByteArray& data){
|
QByteArray {{prefix}}HttpRequestWorker::decompress(const QByteArray& data){
|
||||||
QByteArray result;
|
{{#contentCompression}}QByteArray result;
|
||||||
bool sts = false;{{#contentCompression}}
|
bool sts = false;
|
||||||
do{
|
do{
|
||||||
z_stream strm{};
|
z_stream strm{};
|
||||||
static const int CHUNK_SIZE = 2048;
|
static const int CHUNK_SIZE = 8*1024;
|
||||||
char out[CHUNK_SIZE];
|
char out[CHUNK_SIZE];
|
||||||
if (data.size() <= 4) {
|
if (data.size() <= 4) {
|
||||||
break;
|
break;
|
||||||
@ -427,8 +442,65 @@ QByteArray {{prefix}}HttpRequestWorker::decompress(const QByteArray& data){
|
|||||||
sts = true;
|
sts = true;
|
||||||
} while (strm.avail_out == 0);
|
} while (strm.avail_out == 0);
|
||||||
inflateEnd(&strm);
|
inflateEnd(&strm);
|
||||||
} while(false);{{/contentCompression}}
|
} while(false);
|
||||||
return sts ? result : QByteArray();
|
return sts ? result : QByteArray();{{/contentCompression}}{{^contentCompression}}
|
||||||
|
Q_UNUSED(data);
|
||||||
|
return QByteArray();{{/contentCompression}}
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray {{prefix}}HttpRequestWorker::compress(const QByteArray& input, int level, {{prefix}}CompressionType compressType) {
|
||||||
|
{{#contentCompression}}QByteArray output;
|
||||||
|
static const int GZIP_WINDOW_BIT = 15+16;
|
||||||
|
static const int ZLIB_WINDOW_BIT = 15;
|
||||||
|
static const int CHUNK_SIZE = 8*1024;
|
||||||
|
int windowBits;
|
||||||
|
if( compressType == {{prefix}}CompressionType::Gzip ){
|
||||||
|
windowBits = GZIP_WINDOW_BIT;
|
||||||
|
} else if ( compressType == {{prefix}}CompressionType::Zlib ){
|
||||||
|
windowBits = ZLIB_WINDOW_BIT;
|
||||||
|
}
|
||||||
|
do{
|
||||||
|
int flush = 0, ret = 0;
|
||||||
|
bool error_sts = false;
|
||||||
|
z_stream strm{};
|
||||||
|
if(input.length() <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (deflateInit2(&strm, qMax(-1, qMin(9, level)), Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY) != Z_OK){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
output.clear();
|
||||||
|
auto input_data = input.data();
|
||||||
|
int input_data_left = input.length();
|
||||||
|
do {
|
||||||
|
int chunk_size = qMin(CHUNK_SIZE, input_data_left);
|
||||||
|
strm.next_in = (unsigned char*)input_data;
|
||||||
|
strm.avail_in = chunk_size;
|
||||||
|
input_data += chunk_size;
|
||||||
|
input_data_left -= chunk_size;
|
||||||
|
flush = (input_data_left <= 0 ? Z_FINISH : Z_NO_FLUSH);
|
||||||
|
do {
|
||||||
|
char out[CHUNK_SIZE];
|
||||||
|
strm.next_out = (unsigned char*)out;
|
||||||
|
strm.avail_out = CHUNK_SIZE;
|
||||||
|
ret = deflate(&strm, flush);
|
||||||
|
if(ret == Z_STREAM_ERROR) {
|
||||||
|
error_sts = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto have = (CHUNK_SIZE - strm.avail_out);
|
||||||
|
if(have > 0){
|
||||||
|
output.append((char*)out, have);
|
||||||
|
}
|
||||||
|
} while (strm.avail_out == 0);
|
||||||
|
} while ((flush != Z_FINISH) && !(error_sts));
|
||||||
|
deflateEnd(&strm);
|
||||||
|
} while(false);
|
||||||
|
return output;{{/contentCompression}}{{^contentCompression}}
|
||||||
|
Q_UNUSED(input);
|
||||||
|
Q_UNUSED(level);
|
||||||
|
Q_UNUSED(compressType);
|
||||||
|
return QByteArray();{{/contentCompression}}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSslConfiguration *{{prefix}}HttpRequestWorker::sslDefaultConfiguration;
|
QSslConfiguration *{{prefix}}HttpRequestWorker::sslDefaultConfiguration;
|
||||||
|
@ -63,21 +63,28 @@ public:
|
|||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
{{prefix}}HttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
{{prefix}}HttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
||||||
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
||||||
void setCompressionEnabled(bool enable);
|
void setResponseCompressionEnabled(bool enable);
|
||||||
|
void setRequestCompressionEnabled(bool enable);
|
||||||
signals:
|
signals:
|
||||||
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
|
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum {{prefix}}CompressionType{
|
||||||
|
Zlib,
|
||||||
|
Gzip
|
||||||
|
};
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
QMap<QString, QString> headers;
|
QMap<QString, QString> headers;
|
||||||
QMap<QString, {{prefix}}HttpFileElement> files;
|
QMap<QString, {{prefix}}HttpFileElement> files;
|
||||||
QMap<QString, QByteArray *> multiPartFields;
|
QMap<QString, QByteArray *> multiPartFields;
|
||||||
QString workingDirectory;
|
QString workingDirectory;
|
||||||
int _timeOut;
|
int _timeOut;
|
||||||
bool isCompressionEnabled;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
void on_manager_timeout(QNetworkReply *reply);
|
void on_manager_timeout(QNetworkReply *reply);
|
||||||
void process_response(QNetworkReply *reply);
|
void process_response(QNetworkReply *reply);
|
||||||
QByteArray decompress(const QByteArray& data);
|
QByteArray decompress(const QByteArray& data);
|
||||||
|
QByteArray compress(const QByteArray& input, int level, {{prefix}}CompressionType compressType);
|
||||||
private slots:
|
private slots:
|
||||||
void on_manager_finished(QNetworkReply *reply);
|
void on_manager_finished(QNetworkReply *reply);
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,8 @@ namespace {{this}} {
|
|||||||
_port(port),
|
_port(port),
|
||||||
_basePath(basePath),
|
_basePath(basePath),
|
||||||
_timeOut(timeOut),
|
_timeOut(timeOut),
|
||||||
_compress(false) {}
|
isResponseCompressionEnabled(false),
|
||||||
|
isRequestCompressionEnabled(false) {}
|
||||||
|
|
||||||
{{classname}}::~{{classname}}() {
|
{{classname}}::~{{classname}}() {
|
||||||
}
|
}
|
||||||
@ -48,8 +49,12 @@ void {{classname}}::addHeaders(const QString &key, const QString &value) {
|
|||||||
defaultHeaders.insert(key, value);
|
defaultHeaders.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void {{classname}}::enableContentCompression() {
|
void {{classname}}::enableRequestCompression() {
|
||||||
_compress = true;
|
isRequestCompressionEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void {{classname}}::enableResponseCompression() {
|
||||||
|
isResponseCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
@ -113,8 +118,9 @@ void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName
|
|||||||
{{/collectionFormat}}{{/queryParams}}
|
{{/collectionFormat}}{{/queryParams}}
|
||||||
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this);
|
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);{{#contentCompression}}
|
||||||
worker->setCompressionEnabled(_compress);
|
worker->setResponseCompressionEnabled(isResponseCompressionEnabled);
|
||||||
|
worker->setRequestCompressionEnabled(isRequestCompressionEnabled);{{/contentCompression}}
|
||||||
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
{{#formParams}}{{^isFile}}
|
{{#formParams}}{{^isFile}}
|
||||||
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}}
|
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}}
|
||||||
|
@ -27,7 +27,8 @@ public:
|
|||||||
void setTimeOut(const int timeOut);
|
void setTimeOut(const int timeOut);
|
||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
void addHeaders(const QString &key, const QString &value);
|
void addHeaders(const QString &key, const QString &value);
|
||||||
void enableContentCompression();
|
void enableRequestCompression();
|
||||||
|
void enableResponseCompression();
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}{{#operation}}
|
||||||
void {{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/operation}}{{/operations}}
|
void {{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/operation}}{{/operations}}
|
||||||
|
|
||||||
@ -38,7 +39,8 @@ private:
|
|||||||
int _timeOut;
|
int _timeOut;
|
||||||
QString _workingDirectory;
|
QString _workingDirectory;
|
||||||
QMap<QString, QString> defaultHeaders;
|
QMap<QString, QString> defaultHeaders;
|
||||||
bool _compress;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}{{#operation}}
|
||||||
void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}}
|
void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}}
|
||||||
|
|
||||||
|
@ -103,8 +103,12 @@ void PFXHttpRequestWorker::setWorkingDirectory(const QString &path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXHttpRequestWorker::setCompressionEnabled(bool enable) {
|
void PFXHttpRequestWorker::setResponseCompressionEnabled(bool enable) {
|
||||||
isCompressionEnabled = enable;
|
isResponseCompressionEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PFXHttpRequestWorker::setRequestCompressionEnabled(bool enable) {
|
||||||
|
isRequestCompressionEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
||||||
@ -292,8 +296,12 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
|||||||
if (input->request_body.size() > 0) {
|
if (input->request_body.size() > 0) {
|
||||||
qDebug() << "got a request body";
|
qDebug() << "got a request body";
|
||||||
request_content.clear();
|
request_content.clear();
|
||||||
|
if(!isFormData && (input->var_layout != MULTIPART) && isRequestCompressionEnabled){
|
||||||
|
request_content.append(compress(input->request_body, 7, PFXCompressionType::Gzip));
|
||||||
|
} else {
|
||||||
request_content.append(input->request_body);
|
request_content.append(input->request_body);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// prepare connection
|
// prepare connection
|
||||||
|
|
||||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
@ -309,14 +317,19 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
|||||||
} else {
|
} else {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
||||||
}
|
}
|
||||||
|
if(isRequestCompressionEnabled){
|
||||||
|
request.setRawHeader("Content-Encoding", "gzip");
|
||||||
|
}
|
||||||
} else if (input->var_layout == URL_ENCODED) {
|
} else if (input->var_layout == URL_ENCODED) {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
} else if (input->var_layout == MULTIPART) {
|
} else if (input->var_layout == MULTIPART) {
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isCompressionEnabled){
|
if(isResponseCompressionEnabled){
|
||||||
request.setRawHeader("Accept-Encoding", "deflate, gzip");
|
request.setRawHeader("Accept-Encoding", "gzip");
|
||||||
|
} else {
|
||||||
|
request.setRawHeader("Accept-Encoding", "identity");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->http_method == "GET") {
|
if (input->http_method == "GET") {
|
||||||
@ -398,6 +411,8 @@ void PFXHttpRequestWorker::process_response(QNetworkReply *reply) {
|
|||||||
auto compressionTypes = encoding.first().split(',', QString::SkipEmptyParts);
|
auto compressionTypes = encoding.first().split(',', QString::SkipEmptyParts);
|
||||||
if(compressionTypes.contains("gzip", Qt::CaseInsensitive) || compressionTypes.contains("deflate", Qt::CaseInsensitive)){
|
if(compressionTypes.contains("gzip", Qt::CaseInsensitive) || compressionTypes.contains("deflate", Qt::CaseInsensitive)){
|
||||||
response = decompress(reply->readAll());
|
response = decompress(reply->readAll());
|
||||||
|
} else if(compressionTypes.contains("identity", Qt::CaseInsensitive)){
|
||||||
|
response = reply->readAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,9 +424,17 @@ void PFXHttpRequestWorker::process_response(QNetworkReply *reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QByteArray PFXHttpRequestWorker::decompress(const QByteArray& data){
|
QByteArray PFXHttpRequestWorker::decompress(const QByteArray& data){
|
||||||
QByteArray result;
|
|
||||||
bool sts = false;
|
Q_UNUSED(data);
|
||||||
return sts ? result : QByteArray();
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray PFXHttpRequestWorker::compress(const QByteArray& input, int level, PFXCompressionType compressType) {
|
||||||
|
|
||||||
|
Q_UNUSED(input);
|
||||||
|
Q_UNUSED(level);
|
||||||
|
Q_UNUSED(compressType);
|
||||||
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSslConfiguration *PFXHttpRequestWorker::sslDefaultConfiguration;
|
QSslConfiguration *PFXHttpRequestWorker::sslDefaultConfiguration;
|
||||||
|
@ -71,21 +71,28 @@ public:
|
|||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
PFXHttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
PFXHttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
||||||
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
||||||
void setCompressionEnabled(bool enable);
|
void setResponseCompressionEnabled(bool enable);
|
||||||
|
void setRequestCompressionEnabled(bool enable);
|
||||||
signals:
|
signals:
|
||||||
void on_execution_finished(PFXHttpRequestWorker *worker);
|
void on_execution_finished(PFXHttpRequestWorker *worker);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum PFXCompressionType{
|
||||||
|
Zlib,
|
||||||
|
Gzip
|
||||||
|
};
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
QMap<QString, QString> headers;
|
QMap<QString, QString> headers;
|
||||||
QMap<QString, PFXHttpFileElement> files;
|
QMap<QString, PFXHttpFileElement> files;
|
||||||
QMap<QString, QByteArray *> multiPartFields;
|
QMap<QString, QByteArray *> multiPartFields;
|
||||||
QString workingDirectory;
|
QString workingDirectory;
|
||||||
int _timeOut;
|
int _timeOut;
|
||||||
bool isCompressionEnabled;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
void on_manager_timeout(QNetworkReply *reply);
|
void on_manager_timeout(QNetworkReply *reply);
|
||||||
void process_response(QNetworkReply *reply);
|
void process_response(QNetworkReply *reply);
|
||||||
QByteArray decompress(const QByteArray& data);
|
QByteArray decompress(const QByteArray& data);
|
||||||
|
QByteArray compress(const QByteArray& input, int level, PFXCompressionType compressType);
|
||||||
private slots:
|
private slots:
|
||||||
void on_manager_finished(QNetworkReply *reply);
|
void on_manager_finished(QNetworkReply *reply);
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,8 @@ PFXPetApi::PFXPetApi(const QString &scheme, const QString &host, int port, const
|
|||||||
_port(port),
|
_port(port),
|
||||||
_basePath(basePath),
|
_basePath(basePath),
|
||||||
_timeOut(timeOut),
|
_timeOut(timeOut),
|
||||||
_compress(false) {}
|
isResponseCompressionEnabled(false),
|
||||||
|
isRequestCompressionEnabled(false) {}
|
||||||
|
|
||||||
PFXPetApi::~PFXPetApi() {
|
PFXPetApi::~PFXPetApi() {
|
||||||
}
|
}
|
||||||
@ -56,8 +57,12 @@ void PFXPetApi::addHeaders(const QString &key, const QString &value) {
|
|||||||
defaultHeaders.insert(key, value);
|
defaultHeaders.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXPetApi::enableContentCompression() {
|
void PFXPetApi::enableRequestCompression() {
|
||||||
_compress = true;
|
isRequestCompressionEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PFXPetApi::enableResponseCompression() {
|
||||||
|
isResponseCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXPetApi::addPet(const PFXPet &body) {
|
void PFXPetApi::addPet(const PFXPet &body) {
|
||||||
@ -71,7 +76,6 @@ void PFXPetApi::addPet(const PFXPet &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
@ -120,7 +124,6 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const QString &api_key) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
if (api_key != nullptr) {
|
if (api_key != nullptr) {
|
||||||
@ -205,7 +208,6 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -296,7 +298,6 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -352,7 +353,6 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -396,7 +396,6 @@ void PFXPetApi::updatePet(const PFXPet &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "PUT");
|
PFXHttpRequestInput input(fullPath, "PUT");
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
@ -445,7 +444,6 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QString &name, con
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
input.add_var("name", ::test_namespace::toStringValue(name));
|
input.add_var("name", ::test_namespace::toStringValue(name));
|
||||||
@ -493,7 +491,6 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const QString &additional_metad
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata));
|
input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata));
|
||||||
|
@ -37,7 +37,8 @@ public:
|
|||||||
void setTimeOut(const int timeOut);
|
void setTimeOut(const int timeOut);
|
||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
void addHeaders(const QString &key, const QString &value);
|
void addHeaders(const QString &key, const QString &value);
|
||||||
void enableContentCompression();
|
void enableRequestCompression();
|
||||||
|
void enableResponseCompression();
|
||||||
|
|
||||||
void addPet(const PFXPet &body);
|
void addPet(const PFXPet &body);
|
||||||
void deletePet(const qint64 &pet_id, const QString &api_key);
|
void deletePet(const qint64 &pet_id, const QString &api_key);
|
||||||
@ -55,7 +56,8 @@ private:
|
|||||||
int _timeOut;
|
int _timeOut;
|
||||||
QString _workingDirectory;
|
QString _workingDirectory;
|
||||||
QMap<QString, QString> defaultHeaders;
|
QMap<QString, QString> defaultHeaders;
|
||||||
bool _compress;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
|
|
||||||
void addPetCallback(PFXHttpRequestWorker *worker);
|
void addPetCallback(PFXHttpRequestWorker *worker);
|
||||||
void deletePetCallback(PFXHttpRequestWorker *worker);
|
void deletePetCallback(PFXHttpRequestWorker *worker);
|
||||||
|
@ -23,7 +23,8 @@ PFXStoreApi::PFXStoreApi(const QString &scheme, const QString &host, int port, c
|
|||||||
_port(port),
|
_port(port),
|
||||||
_basePath(basePath),
|
_basePath(basePath),
|
||||||
_timeOut(timeOut),
|
_timeOut(timeOut),
|
||||||
_compress(false) {}
|
isResponseCompressionEnabled(false),
|
||||||
|
isRequestCompressionEnabled(false) {}
|
||||||
|
|
||||||
PFXStoreApi::~PFXStoreApi() {
|
PFXStoreApi::~PFXStoreApi() {
|
||||||
}
|
}
|
||||||
@ -56,8 +57,12 @@ void PFXStoreApi::addHeaders(const QString &key, const QString &value) {
|
|||||||
defaultHeaders.insert(key, value);
|
defaultHeaders.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXStoreApi::enableContentCompression() {
|
void PFXStoreApi::enableRequestCompression() {
|
||||||
_compress = true;
|
isRequestCompressionEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PFXStoreApi::enableResponseCompression() {
|
||||||
|
isResponseCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXStoreApi::deleteOrder(const QString &order_id) {
|
void PFXStoreApi::deleteOrder(const QString &order_id) {
|
||||||
@ -74,7 +79,6 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -117,7 +121,6 @@ void PFXStoreApi::getInventory() {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -173,7 +176,6 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -217,7 +219,6 @@ void PFXStoreApi::placeOrder(const PFXOrder &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
|
@ -36,7 +36,8 @@ public:
|
|||||||
void setTimeOut(const int timeOut);
|
void setTimeOut(const int timeOut);
|
||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
void addHeaders(const QString &key, const QString &value);
|
void addHeaders(const QString &key, const QString &value);
|
||||||
void enableContentCompression();
|
void enableRequestCompression();
|
||||||
|
void enableResponseCompression();
|
||||||
|
|
||||||
void deleteOrder(const QString &order_id);
|
void deleteOrder(const QString &order_id);
|
||||||
void getInventory();
|
void getInventory();
|
||||||
@ -50,7 +51,8 @@ private:
|
|||||||
int _timeOut;
|
int _timeOut;
|
||||||
QString _workingDirectory;
|
QString _workingDirectory;
|
||||||
QMap<QString, QString> defaultHeaders;
|
QMap<QString, QString> defaultHeaders;
|
||||||
bool _compress;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
|
|
||||||
void deleteOrderCallback(PFXHttpRequestWorker *worker);
|
void deleteOrderCallback(PFXHttpRequestWorker *worker);
|
||||||
void getInventoryCallback(PFXHttpRequestWorker *worker);
|
void getInventoryCallback(PFXHttpRequestWorker *worker);
|
||||||
|
@ -23,7 +23,8 @@ PFXUserApi::PFXUserApi(const QString &scheme, const QString &host, int port, con
|
|||||||
_port(port),
|
_port(port),
|
||||||
_basePath(basePath),
|
_basePath(basePath),
|
||||||
_timeOut(timeOut),
|
_timeOut(timeOut),
|
||||||
_compress(false) {}
|
isResponseCompressionEnabled(false),
|
||||||
|
isRequestCompressionEnabled(false) {}
|
||||||
|
|
||||||
PFXUserApi::~PFXUserApi() {
|
PFXUserApi::~PFXUserApi() {
|
||||||
}
|
}
|
||||||
@ -56,8 +57,12 @@ void PFXUserApi::addHeaders(const QString &key, const QString &value) {
|
|||||||
defaultHeaders.insert(key, value);
|
defaultHeaders.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXUserApi::enableContentCompression() {
|
void PFXUserApi::enableRequestCompression() {
|
||||||
_compress = true;
|
isRequestCompressionEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PFXUserApi::enableResponseCompression() {
|
||||||
|
isResponseCompressionEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PFXUserApi::createUser(const PFXUser &body) {
|
void PFXUserApi::createUser(const PFXUser &body) {
|
||||||
@ -71,7 +76,6 @@ void PFXUserApi::createUser(const PFXUser &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
@ -117,7 +121,6 @@ void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
||||||
@ -164,7 +167,6 @@ void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "POST");
|
PFXHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
||||||
@ -214,7 +216,6 @@ void PFXUserApi::deleteUser(const QString &username) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -260,7 +261,6 @@ void PFXUserApi::getUserByName(const QString &username) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -316,7 +316,6 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -361,7 +360,6 @@ void PFXUserApi::logoutUser() {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "GET");
|
PFXHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||||
@ -407,7 +405,6 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
|
|||||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||||
worker->setTimeOut(_timeOut);
|
worker->setTimeOut(_timeOut);
|
||||||
worker->setWorkingDirectory(_workingDirectory);
|
worker->setWorkingDirectory(_workingDirectory);
|
||||||
worker->setCompressionEnabled(_compress);
|
|
||||||
PFXHttpRequestInput input(fullPath, "PUT");
|
PFXHttpRequestInput input(fullPath, "PUT");
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
|
@ -36,7 +36,8 @@ public:
|
|||||||
void setTimeOut(const int timeOut);
|
void setTimeOut(const int timeOut);
|
||||||
void setWorkingDirectory(const QString &path);
|
void setWorkingDirectory(const QString &path);
|
||||||
void addHeaders(const QString &key, const QString &value);
|
void addHeaders(const QString &key, const QString &value);
|
||||||
void enableContentCompression();
|
void enableRequestCompression();
|
||||||
|
void enableResponseCompression();
|
||||||
|
|
||||||
void createUser(const PFXUser &body);
|
void createUser(const PFXUser &body);
|
||||||
void createUsersWithArrayInput(const QList<PFXUser> &body);
|
void createUsersWithArrayInput(const QList<PFXUser> &body);
|
||||||
@ -54,7 +55,8 @@ private:
|
|||||||
int _timeOut;
|
int _timeOut;
|
||||||
QString _workingDirectory;
|
QString _workingDirectory;
|
||||||
QMap<QString, QString> defaultHeaders;
|
QMap<QString, QString> defaultHeaders;
|
||||||
bool _compress;
|
bool isResponseCompressionEnabled;
|
||||||
|
bool isRequestCompressionEnabled;
|
||||||
|
|
||||||
void createUserCallback(PFXHttpRequestWorker *worker);
|
void createUserCallback(PFXHttpRequestWorker *worker);
|
||||||
void createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker);
|
void createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user