I set a proxy for QNetworkManager:

QString name = ui->proxyAddressLineEdit->text(); quint16 port = ui->proxyPortSpinBox->value(); QString user = ui->proxyUserLineEdit->text(); QString pass = ui->proxyPasswordLineEdit->text(); proxy.setHostName(name); proxy.setPort(port); proxy.setUser(user); proxy.setPassword(pass); manager->setProxy(proxy); connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinished(QNetworkReply *))); 

I get the page:

 manager->get(QNetworkRequest(QUrl(urlString))); 

Question! How to find out if a connection to the proxy was successfully established? If it was not, the pages are not loaded, as it should, but how to check it programmatically?

    3 answers 3

    Use reply and check it with isReadable()

      if (!reply->isReadable()) return false; 

      Simply send an HTTP request to any site that is known in advance is available. For example a search engine (google-Yandex). And then you read the answer: if 200 OK, then the norm works.

        Got a page, so it’s working, not received, it’s not working. If you received the answer "the page does not exist", then the page is not found or the problem of blocking the site on the proxy, but this page will give out a proxy, which means the page will be received. There is no sense to test on the address of a specific site such as Google or Yandex, the company can have access through a proxy only to internal sites, but not to external ones, etc. situations. It is necessary to analyze the incoming response to the "request" of the manager.