frangulyan
frangulyan

Reputation: 3847

QNetworkReply::UnknownNetworkError from QNetworkAccessManager::get when requesting https with a password protected proxy server

I'm having a problem with QNetworkAccessManager. Here is some brief description of what I am doing:

QNetworkAccessManager* manager = new QNetworkAccessManager(this);
manager->setProxy(proxy);
QUrl url("https://www.example.com");
QNetworkRequest request(url);
manager->get(request);

In order to test the code on a password protected proxy server I used Polipo. When setting up a password for the server and using a NON-https url (http://www.example.com) I normally get proxyAuthenticationRequired() signal emitted. However, with https urls I don't have that signal (or sslErrors() signal) emitted and finished() signal is emitted with reply->error() equal to QNetworkReply::UnknownNetworkError. I'm sure that this is not a Polipo issue because the browsers are still asking for username/password for proxy server although in case of incorrect credentials they don't say "proxy authentication failed" like for http urls, just say that page cannot be opened. So I need to know how to configure qt classes or its ssl classes to ask for authentication and fix this problem.

I'm using Qt 4.5.2.

Thanks!

Upvotes: 3

Views: 6286

Answers (1)

alexisdm
alexisdm

Reputation: 29886

Even when there is an error, you should check:

  • the reply content reply->readAll(), which might contain the server generated error page,
  • the error text in reply->errorString()
  • the HTTP status code returned by

    reply >attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt()
    

Upvotes: 6

Related Questions