Results 1 to 13 of 13

Thread: QNetworkAccessManager proxy issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation QNetworkAccessManager proxy issue

    I'm having problems getting through a proxy. If I use the following code.

    Qt Code:
    1. QWebView a;
    2. a.load(QUrl("http:\\google.co.uk"));
    3. a.show();
    To copy to clipboard, switch view to plain text mode 
    The request fails, because I'm behind a proxy. Which is fine and I understand that. So if I amend the code to :

    Qt Code:
    1. QNetworkProxyFactory::setUseSystemConfiguration ( true) ;
    2. QWebView a;
    3. a.load(QUrl("http:\\google.co.uk"));
    4. a.show();
    To copy to clipboard, switch view to plain text mode 

    Everything works fine. I see the google page and I'm not prompted to input my proxy user name or password.
    Now this is where I have my problem. I don't want to use a GUI. I'm trying to automate a process at work so I thought I would use QNetworkAccessManager to the same result.

    So heres my code :

    Qt Code:
    1. QUrl a("http://google.co.uk");
    2. QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    3.  
    4. QNetworkProxyQuery npq(a);
    5. QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
    6.  
    7. if (listOfProxies.count() !=0){
    8. if (listOfProxies.at(0).type() != QNetworkProxy::NoProxy) {
    9. manager->setProxy(listOfProxies.at(0));
    10. std::cerr << "Using Proxy " << listOfProxies.at(0).hostName().toStdString() << "\n";
    11. }
    12. }
    13.  
    14. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(outPutPage(QNetworkReply*)));
    15. manager->get(QNetworkRequest(a));
    To copy to clipboard, switch view to plain text mode 
    Now without a proxy this code works fine and I see the HTML printed to the screen. However when running behind a proxy (that requires authentication) I see the code telling me its "Using Proxy" but the code fails even if I supply a valid username and password, it just keeps reporting that the proxy requires authentication. I have tried many different combinations, using QNetworkProxyFactory::setUseSystemConfiguration ( true) ; setting the application proxy.

    Does anyone have any idea how I might resolve this. Or is there a class I can use in the QWebKit that doesn't have the over head of rendering. I'm only interested in the data being sent a received. Or doesn't anyone know what the QWebKit class does differently to QNetworkAccessManager::setProxy?

    All help will be appreciated.

    Regards

    Dan
    Last edited by wysota; 14th January 2010 at 19:21. Reason: reformatted to look better

Similar Threads

  1. HTTP POST / Proxy Authentication issue
    By dekc99 in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2011, 09:59
  2. Replies: 0
    Last Post: 21st December 2009, 05:04
  3. How to Login using QNetworkAccessManager?
    By cydside in forum Newbie
    Replies: 1
    Last Post: 31st August 2009, 21:41
  4. QNetworkAccessManager vs QHttp
    By jiveaxe in forum Newbie
    Replies: 3
    Last Post: 17th February 2009, 14:07
  5. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.