From cfaaf4a2c4cc99edc8bd70341d43260c95b88f0e Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 10 Jul 2013 18:57:52 +0200 Subject: [PATCH] Don't always send Auth headers Use slotAuthentication again instead. --- src/mirall/owncloudinfo.cpp | 20 ++------------------ src/mirall/owncloudinfo.h | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp index 8f3508a67..075d5c4fc 100644 --- a/src/mirall/owncloudinfo.cpp +++ b/src/mirall/owncloudinfo.cpp @@ -64,6 +64,7 @@ ownCloudInfo* ownCloudInfo::instance() ownCloudInfo::ownCloudInfo() : QObject(0), _manager(0), + _authAttempts(0), _lastQuotaTotalBytes(0), _lastQuotaUsedBytes(0) { @@ -88,11 +89,8 @@ void ownCloudInfo::setNetworkAccessManager( QNetworkAccessManager* qnam ) // The authenticationRequired signal is not handled because the creds are set // in the request header. -#if 0 connect( _manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this, SLOT(slotAuthentication(QNetworkReply*,QAuthenticator*))); -#endif - // no cookie jar so far. _manager->setCookieJar(new oCCookieJar); @@ -346,7 +344,6 @@ void ownCloudInfo::slotGetQuotaFinished() #endif // FIXME: remove this later, once the new connection dialog has settled. -#if 0 void ownCloudInfo::slotAuthentication( QNetworkReply *reply, QAuthenticator *auth ) { if( !(auth && reply) ) return; @@ -360,10 +357,8 @@ void ownCloudInfo::slotAuthentication( QNetworkReply *reply, QAuthenticator *aut qDebug() << "Auth request to me and I am " << this; _authAttempts++; - MirallConfigFile cfgFile( configHandle ); qDebug() << "Authenticating request for " << reply->url(); - if( reply->url().toString().startsWith( cfgFile.ownCloudUrl( _connection, true )) ) { - + if( reply->url().toString().startsWith( webdavUrl( _connection ) ) ) { QString con = configHandle; if( con.isEmpty() ) con = DEFAULT_CONNECTION; if( _credentials.contains(con)) { @@ -383,7 +378,6 @@ void ownCloudInfo::slotAuthentication( QNetworkReply *reply, QAuthenticator *aut reply->close(); } } -#endif QString ownCloudInfo::configHandle(QNetworkReply *reply) { @@ -616,16 +610,6 @@ void ownCloudInfo::setupHeaders( QNetworkRequest & req, quint64 size ) qDebug() << "Setting up host header: " << url.host(); req.setRawHeader( QByteArray("User-Agent"), Utility::userAgentString()); - QString con = _configHandle; - if( con.isEmpty() ) con = DEFAULT_CONNECTION; - if( _credentials.contains(con)) { - oCICredentials creds = _credentials.value(con); - QString concatenated = creds.user + QLatin1Char(':') + creds.passwd; - const QString b(QLatin1String("Basic ")); - QByteArray data = b.toUtf8() + concatenated.toUtf8().toBase64(); - req.setRawHeader( QByteArray("Authorization"), data ); - } - if (size) { req.setHeader( QNetworkRequest::ContentLengthHeader, size); req.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml; charset=utf-8")); diff --git a/src/mirall/owncloudinfo.h b/src/mirall/owncloudinfo.h index d4fd66170..9060fdd7a 100644 --- a/src/mirall/owncloudinfo.h +++ b/src/mirall/owncloudinfo.h @@ -132,7 +132,7 @@ signals: protected slots: void slotReplyFinished( ); void slotError( QNetworkReply::NetworkError ); - // void slotAuthentication( QNetworkReply*, QAuthenticator *); + void slotAuthentication( QNetworkReply*, QAuthenticator *); #if QT46_IMPL void qhttpRequestFinished(int id, bool success );