added DELETE and PUT methods
This commit is contained in:
parent
c3fc131c22
commit
e69b3513a4
3 changed files with 21 additions and 6 deletions
|
@ -228,7 +228,7 @@ void KQOAuthManager::executeRequest(KQOAuthRequest *request) {
|
||||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||||
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
||||||
|
|
||||||
} else if (request->httpMethod() == KQOAuthRequest::POST) {
|
} else if (request->httpMethod() == KQOAuthRequest::POST || request->httpMethod() == KQOAuthRequest::DELETE || request->httpMethod() == KQOAuthRequest::PUT) {
|
||||||
|
|
||||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
||||||
|
|
||||||
|
@ -237,7 +237,11 @@ void KQOAuthManager::executeRequest(KQOAuthRequest *request) {
|
||||||
qDebug() << networkRequest.rawHeader("Content-Type");
|
qDebug() << networkRequest.rawHeader("Content-Type");
|
||||||
|
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply;
|
||||||
if (request->contentType() == "application/x-www-form-urlencoded") {
|
if (request->httpMethod() == KQOAuthRequest::PUT) {
|
||||||
|
reply = d->networkManager->put(networkRequest, request->requestBody());
|
||||||
|
} else if (request->httpMethod() == KQOAuthRequest::DELETE) {
|
||||||
|
reply = d->networkManager->deleteResource(networkRequest);
|
||||||
|
} else if (request->contentType() == "application/x-www-form-urlencoded") {
|
||||||
reply = d->networkManager->post(networkRequest, request->requestBody());
|
reply = d->networkManager->post(networkRequest, request->requestBody());
|
||||||
} else {
|
} else {
|
||||||
reply = d->networkManager->post(networkRequest, request->rawData());
|
reply = d->networkManager->post(networkRequest, request->rawData());
|
||||||
|
@ -342,8 +346,7 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||||
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
this, SLOT(slotError(QNetworkReply::NetworkError)));
|
||||||
|
|
||||||
} else if (request->httpMethod() == KQOAuthRequest::POST) {
|
} else if (request->httpMethod() == KQOAuthRequest::POST || request->httpMethod() == KQOAuthRequest::DELETE || request->httpMethod() == KQOAuthRequest::PUT) {
|
||||||
|
|
||||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
|
||||||
|
|
||||||
QByteArray argHeader;
|
QByteArray argHeader;
|
||||||
|
@ -355,7 +358,11 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
|
||||||
qDebug() << networkRequest.rawHeader("Content-Type");
|
qDebug() << networkRequest.rawHeader("Content-Type");
|
||||||
|
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply;
|
||||||
if (request->contentType() == "application/x-www-form-urlencoded") {
|
if (request->httpMethod() == KQOAuthRequest::PUT) {
|
||||||
|
reply = d->networkManager->put(networkRequest, request->requestBody());
|
||||||
|
} else if (request->httpMethod() == KQOAuthRequest::DELETE) {
|
||||||
|
reply = d->networkManager->deleteResource(networkRequest);
|
||||||
|
} else if (request->contentType() == "application/x-www-form-urlencoded") {
|
||||||
reply = d->networkManager->post(networkRequest, request->requestBody());
|
reply = d->networkManager->post(networkRequest, request->requestBody());
|
||||||
} else {
|
} else {
|
||||||
reply = d->networkManager->post(networkRequest, request->rawData());
|
reply = d->networkManager->post(networkRequest, request->rawData());
|
||||||
|
|
|
@ -387,6 +387,12 @@ void KQOAuthRequest::setHttpMethod(KQOAuthRequest::RequestHttpMethod httpMethod)
|
||||||
case KQOAuthRequest::POST:
|
case KQOAuthRequest::POST:
|
||||||
requestHttpMethodString = "POST";
|
requestHttpMethodString = "POST";
|
||||||
break;
|
break;
|
||||||
|
case KQOAuthRequest::PUT:
|
||||||
|
requestHttpMethodString = "PUT";
|
||||||
|
break;
|
||||||
|
case KQOAuthRequest::DELETE:
|
||||||
|
requestHttpMethodString = "DELETE";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning() << "Invalid HTTP method set.";
|
qWarning() << "Invalid HTTP method set.";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -54,7 +54,9 @@ public:
|
||||||
|
|
||||||
enum RequestHttpMethod {
|
enum RequestHttpMethod {
|
||||||
GET = 0,
|
GET = 0,
|
||||||
POST
|
POST,
|
||||||
|
PUT,
|
||||||
|
DELETE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RequestOAuthMethod {
|
enum RequestOAuthMethod {
|
||||||
|
|
Loading…
Reference in a new issue