mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
Revert "Temporarily log HTTP traffic done by MirallAccessManager."
This reverts commit 5930ca8ac7
.
This commit is contained in:
parent
00e819bd92
commit
ee1b8465a3
3 changed files with 1 additions and 122 deletions
|
@ -231,8 +231,6 @@ void HttpCredentials::slotAuthentication(QNetworkReply* reply, QAuthenticator* a
|
|||
qDebug() << "Too many attempts to authenticate. Stop request.";
|
||||
reply->close();
|
||||
} else {
|
||||
reply->setProperty("mirall-user", _user);
|
||||
reply->setProperty("mirall-password", _password);
|
||||
authenticator->setUser( _user );
|
||||
authenticator->setPassword( _password );
|
||||
}
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "mirall/mirallaccessmanager.h"
|
||||
#include "mirall/utility.h"
|
||||
|
@ -22,126 +19,16 @@
|
|||
namespace Mirall
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
QString
|
||||
operationToString (QNetworkAccessManager::Operation op)
|
||||
{
|
||||
switch (op) {
|
||||
case QNetworkAccessManager::HeadOperation:
|
||||
return QString::fromLatin1 ("HEAD");
|
||||
|
||||
case QNetworkAccessManager::GetOperation:
|
||||
return QString::fromLatin1 ("GET");
|
||||
|
||||
case QNetworkAccessManager::PutOperation:
|
||||
return QString::fromLatin1 ("PUT");
|
||||
|
||||
case QNetworkAccessManager::PostOperation:
|
||||
return QString::fromLatin1 ("POST");
|
||||
|
||||
case QNetworkAccessManager::DeleteOperation:
|
||||
return QString::fromLatin1 ("DELETE");
|
||||
|
||||
case QNetworkAccessManager::CustomOperation:
|
||||
return QString::fromLatin1 ("CUSTOM");
|
||||
|
||||
case QNetworkAccessManager::UnknownOperation:
|
||||
return QString::fromLatin1 ("UNKNOWN");
|
||||
}
|
||||
|
||||
return QString::fromLatin1 ("PLAIN WRONG");
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
MirallAccessManager::MirallAccessManager(QObject* parent)
|
||||
: QNetworkAccessManager (parent)
|
||||
{}
|
||||
|
||||
QNetworkReply* MirallAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
|
||||
{
|
||||
static unsigned int staticRequestNo(0);
|
||||
|
||||
unsigned int requestNo(staticRequestNo++);
|
||||
QNetworkRequest newRequest(request);
|
||||
|
||||
newRequest.setRawHeader( QByteArray("User-Agent"), Utility::userAgentString());
|
||||
|
||||
QNetworkReply* reply(QNetworkAccessManager::createRequest (op, newRequest, outgoingData));
|
||||
|
||||
logRequest(requestNo, op, newRequest, outgoingData);
|
||||
connect (reply, SIGNAL(finished()),
|
||||
this, SLOT(logReply()));
|
||||
reply->setProperty("mirall-request-no", QVariant(requestNo));
|
||||
return reply;
|
||||
}
|
||||
|
||||
void MirallAccessManager::logRequest(unsigned int requestNo, QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
|
||||
{
|
||||
QString log;
|
||||
QTextStream stream (&log);
|
||||
QVariant variant = request.attribute (QNetworkRequest::CustomVerbAttribute);
|
||||
|
||||
stream << "\nREQUEST NO: " << requestNo
|
||||
<< "\nRequest operation: " << operationToString (op)
|
||||
<< "\nRequest URL: " << request.url ().toString ();
|
||||
if (variant.isValid ()) {
|
||||
stream << "Request custom operation: " << variant.toByteArray () << "\n";
|
||||
}
|
||||
stream << "\nRequest headers:\n";
|
||||
Q_FOREACH (const QByteArray& header, request.rawHeaderList ()) {
|
||||
stream << " " << header << ": " << request.rawHeader (header) << "\n";
|
||||
}
|
||||
if (outgoingData) {
|
||||
stream << "Body:\n" << outgoingData->peek(outgoingData->bytesAvailable()) << "\n";
|
||||
}
|
||||
stream << "----------\n";
|
||||
qDebug() << log;
|
||||
}
|
||||
|
||||
void MirallAccessManager::logReply()
|
||||
{
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* > (sender());
|
||||
|
||||
if (!reply) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect (reply, SIGNAL(finished()),
|
||||
this, SLOT(logReply()));
|
||||
|
||||
unsigned int requestNo(reply->property("mirall-request-no").toUInt());
|
||||
QString log;
|
||||
QTextStream stream (&log);
|
||||
QVariant variant = reply->property ("mirall-user");
|
||||
|
||||
stream << "\nREPLY TO REQUEST NO: " << requestNo << "\n";
|
||||
if (variant.isValid()) {
|
||||
stream << "Auth user: " << variant.toString() << "\n"
|
||||
<< "Auth password: " << reply->property("mirall-password").toString() << "\n";
|
||||
}
|
||||
variant = reply->attribute (QNetworkRequest::HttpStatusCodeAttribute);
|
||||
if (variant.isValid ()) {
|
||||
stream << "Reply status: " << variant.toInt () << "\n";
|
||||
}
|
||||
variant = reply->attribute (QNetworkRequest::HttpReasonPhraseAttribute);
|
||||
if (variant.isValid ()) {
|
||||
stream << "Reply reason: " << variant.toByteArray () << "\n";
|
||||
}
|
||||
variant = reply->attribute (QNetworkRequest::RedirectionTargetAttribute);
|
||||
if (variant.isValid ()) {
|
||||
stream << "Reply redirection: " << variant.toUrl ().toString () << "\n";
|
||||
}
|
||||
stream << "Reply headers:\n";
|
||||
Q_FOREACH (const QByteArray& header, reply->rawHeaderList ()) {
|
||||
stream << " " << header << ": " << reply->rawHeader (header) << "\n";
|
||||
}
|
||||
stream << "Reply data:\n"
|
||||
<< reply->peek (reply->bytesAvailable ())
|
||||
<< "\n----------\n";
|
||||
qDebug() << log;
|
||||
return QNetworkAccessManager::createRequest (op, newRequest, outgoingData);
|
||||
}
|
||||
|
||||
} // ns Mirall
|
||||
|
|
|
@ -28,12 +28,6 @@ public:
|
|||
|
||||
protected:
|
||||
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData = 0);
|
||||
|
||||
private Q_SLOTS:
|
||||
void logReply();
|
||||
|
||||
private:
|
||||
void logRequest(unsigned int requestNo, QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData);
|
||||
};
|
||||
|
||||
} // ns Mirall
|
||||
|
|
Loading…
Reference in a new issue