Merge branch 'issue-1540' into calamares

FIXES #1540
This commit is contained in:
Adriaan de Groot 2020-10-16 13:56:52 +02:00
commit d63e23b289
3 changed files with 16 additions and 3 deletions

View File

@ -113,7 +113,9 @@ do_query( Handler::Type type, const QString& url, const QString& selector )
return RegionZonePair(); return RegionZonePair();
} }
return interface->processReply( CalamaresUtils::Network::Manager::instance().synchronousGet( url ) ); using namespace CalamaresUtils::Network;
return interface->processReply(
CalamaresUtils::Network::Manager::instance().synchronousGet( url, { RequestOptions::FakeUserAgent } ) );
} }
static QString static QString
@ -125,7 +127,9 @@ do_raw_query( Handler::Type type, const QString& url, const QString& selector )
return QString(); return QString();
} }
return interface->rawReply( CalamaresUtils::Network::Manager::instance().synchronousGet( url ) ); using namespace CalamaresUtils::Network;
return interface->rawReply(
CalamaresUtils::Network::Manager::instance().synchronousGet( url, { RequestOptions::FakeUserAgent } ) );
} }
RegionZonePair RegionZonePair

View File

@ -11,7 +11,6 @@
* This is a test-application that does one GeoIP parse. * This is a test-application that does one GeoIP parse.
*/ */
#include <iostream>
#include "GeoIPFixed.h" #include "GeoIPFixed.h"
#include "GeoIPJSON.h" #include "GeoIPJSON.h"
@ -19,6 +18,10 @@
#include "GeoIPXML.h" #include "GeoIPXML.h"
#endif #endif
#include "utils/Logger.h"
#include <iostream>
using std::cerr; using std::cerr;
using namespace CalamaresUtils::GeoIP; using namespace CalamaresUtils::GeoIP;
@ -34,6 +37,9 @@ main( int argc, char** argv )
QString format( argv[ 1 ] ); QString format( argv[ 1 ] );
QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString(); QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString();
Logger::setupLogLevel(Logger::LOGVERBOSE);
cDebug() << "Doing GeoIP interpretation with format=" << format << "selector=" << selector;
Interface* handler = nullptr; Interface* handler = nullptr;
if ( QStringLiteral( "json" ) == format ) if ( QStringLiteral( "json" ) == format )
{ {

View File

@ -223,6 +223,7 @@ synchronousRun( QNetworkAccessManager* nam, const QUrl& url, const RequestOption
auto* reply = asynchronousRun( nam, url, options ); auto* reply = asynchronousRun( nam, url, options );
if ( !reply ) if ( !reply )
{ {
cDebug() << "Could not create request for" << url;
return qMakePair( RequestStatus( RequestStatus::Failed ), nullptr ); return qMakePair( RequestStatus( RequestStatus::Failed ), nullptr );
} }
@ -232,10 +233,12 @@ synchronousRun( QNetworkAccessManager* nam, const QUrl& url, const RequestOption
reply->deleteLater(); reply->deleteLater();
if ( reply->isRunning() ) if ( reply->isRunning() )
{ {
cDebug() << "Timeout on request for" << url;
return qMakePair( RequestStatus( RequestStatus::Timeout ), nullptr ); return qMakePair( RequestStatus( RequestStatus::Timeout ), nullptr );
} }
else if ( reply->error() != QNetworkReply::NoError ) else if ( reply->error() != QNetworkReply::NoError )
{ {
cDebug() << "HTTP error" << reply->error() << "on request for" << url;
return qMakePair( RequestStatus( RequestStatus::HttpError ), nullptr ); return qMakePair( RequestStatus( RequestStatus::HttpError ), nullptr );
} }
else else