From 2427382830fa49acf9bf86913f7f04b56e464a27 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 5 Jun 2013 21:32:09 +0200 Subject: [PATCH] * When redirecting a request, make sure HEAD ops don't become a GET. --- src/libtomahawk/utils/NetworkReply.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/utils/NetworkReply.cpp b/src/libtomahawk/utils/NetworkReply.cpp index 698204030..45f5873e9 100644 --- a/src/libtomahawk/utils/NetworkReply.cpp +++ b/src/libtomahawk/utils/NetworkReply.cpp @@ -21,6 +21,8 @@ #include "utils/TomahawkUtils.h" #include "utils/Logger.h" +#include + using namespace Tomahawk; @@ -61,7 +63,19 @@ NetworkReply::load( const QUrl& url ) QNetworkRequest request( url ); Q_ASSERT( TomahawkUtils::nam() != 0 ); - m_reply = TomahawkUtils::nam()->get( request ); + + QNetworkAccessManager::Operation op = m_reply->operation(); + m_reply->deleteLater(); + + switch ( op ) + { + case QNetworkAccessManager::HeadOperation: + m_reply = TomahawkUtils::nam()->head( request ); + break; + + default: + m_reply = TomahawkUtils::nam()->get( request ); + } connect( m_reply, SIGNAL( finished() ), SLOT( networkLoadFinished() ) ); connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SIGNAL( error( QNetworkReply::NetworkError ) ) ); @@ -82,7 +96,6 @@ NetworkReply::networkLoadFinished() if ( redir.isValid() && !redir.toUrl().isEmpty() ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Redirected HTTP request to" << redir; - m_reply->deleteLater(); load( redir.toUrl() ); emit redirected(); }