@@ -116,6 +116,10 @@ class TestQgsNetworkAccessManager : public QObject
116
116
void testAuthRequestHandler ();
117
117
void fetchTimeout ();
118
118
119
+ private:
120
+
121
+ QString mHttpBinHost ;
122
+
119
123
};
120
124
121
125
void TestQgsNetworkAccessManager::initTestCase ()
@@ -129,6 +133,11 @@ void TestQgsNetworkAccessManager::initTestCase()
129
133
QgsApplication::initQgis ();
130
134
131
135
QgsSettings ().setValue ( QStringLiteral ( " /qgis/networkAndProxy/networkTimeout" ), 1000 );
136
+
137
+ mHttpBinHost = QStringLiteral ( " httpbin.org" );
138
+ QString overrideHost = qgetenv ( " QGIS_HTTPBIN_HOST" );
139
+ if ( !overrideHost.isEmpty () )
140
+ mHttpBinHost = overrideHost;
132
141
}
133
142
134
143
void TestQgsNetworkAccessManager::cleanupTestCase ()
@@ -320,7 +329,7 @@ void TestQgsNetworkAccessManager::fetchPost()
320
329
bool loaded = false ;
321
330
bool gotRequestAboutToBeCreatedSignal = false ;
322
331
int requestId = -1 ;
323
- QUrl u = QUrl ( QStringLiteral ( " http://httpbin.org /post" ) );
332
+ QUrl u = QUrl ( QStringLiteral ( " http://" ) + mHttpBinHost + QStringLiteral ( " /post" ) );
324
333
connect ( QgsNetworkAccessManager::instance (), qgis::overload< QgsNetworkRequestParameters >::of ( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params )
325
334
{
326
335
gotRequestAboutToBeCreatedSignal = true ;
@@ -525,7 +534,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler()
525
534
QString expectedUser;
526
535
QString expectedPassword;
527
536
int requestId = -1 ;
528
- QUrl u = QUrl ( QStringLiteral ( " http://httpbin.org /basic-auth/me/secret" ) );
537
+ QUrl u = QUrl ( QStringLiteral ( " http://" ) + mHttpBinHost + QStringLiteral ( " /basic-auth/me/secret" ) );
529
538
QNetworkReply::NetworkError expectedError = QNetworkReply::NoError;
530
539
connect ( QgsNetworkAccessManager::instance (), qgis::overload< QgsNetworkRequestParameters >::of ( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params )
531
540
{
@@ -606,7 +615,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler()
606
615
607
616
// correct username and password, in a thread
608
617
QgsNetworkAccessManager::instance ()->setAuthHandler ( qgis::make_unique< TestAuthRequestHandler >( QStringLiteral ( " me2" ), QStringLiteral ( " secret2" ) ) );
609
- u = QUrl ( QStringLiteral ( " http://httpbin.org /basic-auth/me2/secret2" ) );
618
+ u = QUrl ( QStringLiteral ( " http://" ) + mHttpBinHost + QStringLiteral ( " /basic-auth/me2/secret2" ) );
610
619
loaded = false ;
611
620
gotAuthRequest = false ;
612
621
gotRequestAboutToBeCreatedSignal = false ;
@@ -644,7 +653,7 @@ void TestQgsNetworkAccessManager::fetchTimeout()
644
653
bool gotTimeoutError = false ;
645
654
bool finished = false ;
646
655
int requestId = -1 ;
647
- QUrl u = QUrl ( QStringLiteral ( " http://httpbin.org /delay/10" ) );
656
+ QUrl u = QUrl ( QStringLiteral ( " http://" ) + mHttpBinHost + QStringLiteral ( " /delay/10" ) );
648
657
connect ( QgsNetworkAccessManager::instance (), qgis::overload< QgsNetworkRequestParameters >::of ( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params )
649
658
{
650
659
gotRequestAboutToBeCreatedSignal = true ;
0 commit comments