void ShtirlitzTask::run() { stateInfo.setDescription( tr("Connecting to remote server") ); //Creating SyncHttp object and enabling proxy if needed. SyncHttp http(stateInfo, this); NetworkConfiguration * nc = AppContext::getAppSettings()->getNetworkConfiguration(); bool isProxy = nc->isProxyUsed( QNetworkProxy::HttpProxy ); bool isException = nc->getExceptionsList().contains( QUrl(DESTINATION_URL_KEEPER_SRV).host() ); if (isProxy && !isException) { http.setProxy(nc->getProxy(QNetworkProxy::HttpProxy)); } QByteArray preparedReport("data="); preparedReport += QUrl::toPercentEncoding(report); // Get actual location of the reports receiver //FIXME: error handling QString reportsPath = http.syncGet( QUrl(QString(DESTINATION_URL_KEEPER_SRV) + QString(DESTINATION_URL_KEEPER_PAGE)) ); if( reportsPath.isEmpty() ) { stateInfo.setError( tr("Cannot resolve destination path for statistical reports") ); return; } if( QNetworkReply::NoError != http.error() ) { stateInfo.setError( tr("Network error while resolving destination URL: ") + http.errorString() ); return; } //Checking proxy again, for the new url SyncHttp http2(stateInfo, this); isException = nc->getExceptionsList().contains( QUrl(reportsPath).host() ); if( isProxy && !isException ) { http2.setProxy( nc->getProxy(QNetworkProxy::HttpProxy) ); } QString fullPath = reportsPath + "?" + preparedReport; http2.syncGet(fullPath); //TODO: consider using POST method? if( QNetworkReply::NoError != http.error() ) { stateInfo.setError( tr("Network error while sending report: ") + http2.errorString() ); return; } }
void test_nghttp2_npn(void) { http2(); http11(); no_overlap(); }