[Qt-interest] adding HTTP Proxy support

Paul Miller paul at fxtech.com
Thu Jul 2 00:18:20 CEST 2009


Paul Miller wrote:
> I have an application that downloads some data from a web site using 
> QNetworkAccessManager::post().
> 
> I want to add proxy support, so I've added some UI that allows the user 
> to enter a hostname, port, username, and password, and then sets the 
> proxy using QNetworkAccessManager::setProxy(). The proxy type is Http.
> 
> I'm trying to test this, and it's not working. I installed squid on a 
> Linux box and verified that it works by setting the proxy settings (just 
> host and port) in Firefox. I'm entering the same information into my 
> QNetworkProxy object and my QNetworkReply is coming back very quickly 
> with "HTTP request failed".
> 
> Any suggestions? The documentation makes it sound like this is all I 
> need to do.

BTW, I eventually figured it out.

Apparently you can't do this:

QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);

You have to do this:

QNetworkProxy proxy(QNetworkProxy::HttpProxy);

I have no idea why - or why there is a setType() method then.

-- 
Paul Miller | paul at fxtech.com | www.fxtech.com | Got Tivo?




More information about the Qt-interest-old mailing list