On Tue, Apr 01, 2008 at 04:57:32PM +0200, Thiago Macieira wrote: > Mohammed Sameer wrote: > >Hi, > >I'm not sure whether this is the right list or not. Sorry if it's not. > > It is. > > >Currently, QNetworkAccessManager allows setting a global proxy but what > > if I wanted to use a different proxy per connection ? > > Set the proxy, send one request, then set another proxy, send another > request. > > My goal for Qt 4.5 is to allow you to set a "proxy factory" class, so that > you can determine which proxy to use based on the connection parameters > (protocol, host and port). > > >My current use case is a browser that is using a PAC file to configure > > the proxy. Which means that one might use a different proxy per > > connection. Maybe even a different proxy per protocol (HTTP/HTTPS/FTP)! > > > >Any ideas how to implement this ? > > That's exactly what I want to solve in Qt 4.5. You keep the PAC script > pre-parsed inside QtScript and you evaluate at every connection. > > Right you, you need to roll out your own solution. A simple way is to > derive from QNetworkAccessManager and override the protected > createRequest() function. You set the proxy on the manager before calling > the base implementation of the function. > > >I can subclass QNetworkProxy and return a different proxy HostName but > > the problem is that QNetworkProxy is not aware of the host we are > > connecting to. > > QNetworkAccessManager::createRequest() is.
Yup, that's great. Probably one should detect a proxy failure and try another one in case multiple proxies can be used. This is a bit tricky I guess but I'm still working on the PAC parser. I was really impressed when I discovered that QScriptEngine can parse a PAC file ;-) Thanks for the tips. -- GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F 280E CB66 8E29 A3FD 0DF7 Debian User and Developer. Homepage: www.foolab.org
signature.asc
Description: Digital signature
