better handling of reset outstanding requests, and shorter timeout2; refs #5
This commit is contained in:
@@ -114,6 +114,9 @@ namespace proxy {
|
||||
#ifdef QT_NETWORK_LIB
|
||||
//! Reset, stop all outstanding checks
|
||||
void reset() {
|
||||
if (_requests.size() || _timeout1.isActive() || _timeout2.isActive())
|
||||
// error when we need to abort
|
||||
proxyError(QNetworkReply::TimeoutError);
|
||||
_timeout1.stop();
|
||||
_timeout2.stop();
|
||||
for (Requests::iterator it(_requests.begin());
|
||||
@@ -122,7 +125,10 @@ namespace proxy {
|
||||
_requests.clear();
|
||||
}
|
||||
//! Network Ping: Check access to a given address using default proxy.
|
||||
void ping(const std::string& url, int timeout2=30000) {
|
||||
void ping(const std::string& url, int timeout2=5000) {
|
||||
if (_requests.size() || _timeout1.isActive() || _timeout2.isActive())
|
||||
// detection is already running, wait for that, don't restart
|
||||
return;
|
||||
reset();
|
||||
_timeout2.setSingleShot(true);
|
||||
_timeout2.setInterval(timeout2);
|
||||
@@ -132,10 +138,10 @@ namespace proxy {
|
||||
setupProxyCheck(defaultProxy, url);
|
||||
_timeout2.start();
|
||||
}
|
||||
void ping(const QUrl& url, int timeout2=30000) {
|
||||
void ping(const QUrl& url, int timeout2=5000) {
|
||||
ping(url.toString().toStdString(), timeout2);
|
||||
}
|
||||
void ping(const QString& url, int timeout2=30000) {
|
||||
void ping(const QString& url, int timeout2=5000) {
|
||||
ping(url.toStdString(), timeout2);
|
||||
}
|
||||
//! If Qt Network is available you may check the proxies found
|
||||
@@ -150,7 +156,7 @@ namespace proxy {
|
||||
@param url the url to find a proxy for
|
||||
@param timeout [ms] time to give up search */
|
||||
void proxy(const std::string& url,
|
||||
int timeout1=5000, int timeout2=30000) {
|
||||
int timeout1=5000, int timeout2=5000) {
|
||||
PROXYFACE_LOG;
|
||||
qDebug()<<"Search proxy for URL, direct and default"
|
||||
<<"url="<<url.data()<<"timeout1="<<timeout1;
|
||||
@@ -169,13 +175,13 @@ namespace proxy {
|
||||
}
|
||||
//! If Qt Network is available you may check the proxies found
|
||||
/*! @copydoc proxy(const std::string&, int) */
|
||||
void proxy(const QUrl& url, int timeout1=5000, int timeout2=30000) {
|
||||
void proxy(const QUrl& url, int timeout1=5000, int timeout2=5000) {
|
||||
PROXYFACE_LOG;
|
||||
proxy(url.toString().toStdString(), timeout1, timeout2);
|
||||
}
|
||||
//! If Qt Network is available you may check the proxies found
|
||||
/*! @copydoc proxy(const std::string&, int) */
|
||||
void proxy(const QString& url, int timeout1=5000, int timeout2=30000) {
|
||||
void proxy(const QString& url, int timeout1=5000, int timeout2=5000) {
|
||||
PROXYFACE_LOG;
|
||||
proxy(url.toStdString(), timeout1, timeout2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user