diff --git a/oauth/kqoauthmanager.cpp b/oauth/kqoauthmanager.cpp index 4a678ff..c7ff0ad 100644 --- a/oauth/kqoauthmanager.cpp +++ b/oauth/kqoauthmanager.cpp @@ -228,7 +228,7 @@ void KQOAuthManager::executeRequest(KQOAuthRequest *request) { connect(reply, SIGNAL(error(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()); @@ -237,7 +237,11 @@ void KQOAuthManager::executeRequest(KQOAuthRequest *request) { qDebug() << networkRequest.rawHeader("Content-Type"); 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()); } else { reply = d->networkManager->post(networkRequest, request->rawData()); @@ -342,8 +346,7 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) { connect(reply, SIGNAL(error(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()); QByteArray argHeader; @@ -355,7 +358,11 @@ void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) { qDebug() << networkRequest.rawHeader("Content-Type"); 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()); } else { reply = d->networkManager->post(networkRequest, request->rawData()); diff --git a/oauth/kqoauthrequest.cpp b/oauth/kqoauthrequest.cpp index e81b56d..50031c2 100644 --- a/oauth/kqoauthrequest.cpp +++ b/oauth/kqoauthrequest.cpp @@ -387,6 +387,12 @@ void KQOAuthRequest::setHttpMethod(KQOAuthRequest::RequestHttpMethod httpMethod) case KQOAuthRequest::POST: requestHttpMethodString = "POST"; break; + case KQOAuthRequest::PUT: + requestHttpMethodString = "PUT"; + break; + case KQOAuthRequest::DELETE: + requestHttpMethodString = "DELETE"; + break; default: qWarning() << "Invalid HTTP method set."; break; diff --git a/oauth/kqoauthrequest.h b/oauth/kqoauthrequest.h index 616003d..77d1520 100644 --- a/oauth/kqoauthrequest.h +++ b/oauth/kqoauthrequest.h @@ -54,7 +54,9 @@ public: enum RequestHttpMethod { GET = 0, - POST + POST, + PUT, + DELETE }; enum RequestOAuthMethod {