From 8881a58c953dd2a703bcbeead9e1574b33865bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 10 Jul 2021 12:51:36 +0200 Subject: [PATCH] Handle 'Location' header reply in drmprocessorclientimpl --- include/libgourou.h | 2 +- include/libgourou_common.h | 3 ++- utils/drmprocessorclientimpl.cpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/libgourou.h b/include/libgourou.h index ae7613b..b32a895 100644 --- a/include/libgourou.h +++ b/include/libgourou.h @@ -40,7 +40,7 @@ #define ACS_SERVER "http://adeactivate.adobe.com/adept" #endif -#define LIBGOUROU_VERSION "0.2" +#define LIBGOUROU_VERSION "0.2.1" namespace gourou { diff --git a/include/libgourou_common.h b/include/libgourou_common.h index 5e20375..c9fa486 100644 --- a/include/libgourou_common.h +++ b/include/libgourou_common.h @@ -107,7 +107,8 @@ namespace gourou CLIENT_BAD_KEY_SIZE, CLIENT_BAD_ZIP_FILE, CLIENT_ZIP_ERROR, - CLIENT_GENERIC_EXCEPTION + CLIENT_GENERIC_EXCEPTION, + CLIENT_NETWORK_ERROR, }; diff --git a/utils/drmprocessorclientimpl.cpp b/utils/drmprocessorclientimpl.cpp index d98474d..bc11a0f 100644 --- a/utils/drmprocessorclientimpl.cpp +++ b/utils/drmprocessorclientimpl.cpp @@ -111,6 +111,24 @@ std::string DRMProcessorClientImpl::sendHTTPRequest(const std::string& URL, cons while (!reply->isFinished()) app->processEvents(); + QByteArray location = reply->rawHeader("Location"); + if (location.size() != 0) + { + GOUROU_LOG(gourou::DEBUG, "New location"); + return sendHTTPRequest(location.constData(), POSTData, contentType); + } + + if (reply->error() != QNetworkReply::NoError) + EXCEPTION(gourou::CLIENT_NETWORK_ERROR, "Error " << reply->error()); + + if (gourou::logLevel >= gourou::DEBUG) + { + QList headers = reply->rawHeaderList(); + for (int i = 0; i < headers.size(); ++i) { + std::cout << headers[i].constData() << " : " << reply->rawHeader(headers[i]).constData() << std::endl; + } + } + replyData = reply->readAll(); if (reply->rawHeader("Content-Type") == "application/vnd.adobe.adept+xml") {