Results 1 to 3 of 3

Thread: posting to an invalid URL using QNetworkAccessManager

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default posting to an invalid URL using QNetworkAccessManager

    Hi Everyone, I have a simple requirement on my Arm-Linux embedded platform wherein I need to post to a URL and wait for the reply. I achieve that using the following code-
    Qt Code:
    1. void MyApp::MyApp()
    2. {
    3. m_networkManager = new QNetworkAccessManager(this); // Instance variable
    4. connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
    5. this, SLOT(onRequestCompleted(QNetworkReply *)));
    6. }
    7.  
    8. void MyApp::getData()
    9. {
    10. QByteArray dataToBePosted;
    11. QNetworkRequest request;
    12. request.setUrl(QUrl("http://www.domain.foo"));
    13. m_networkManager->post(request,dataToBePosted);
    14. }
    15.  
    16. void MyApp::onRequestCompleted(QNetworkReply *reply)
    17. {
    18. QByteArray data = reply->readAll();
    19. reply->deleteLater();
    20. }
    To copy to clipboard, switch view to plain text mode 

    I have 2 doubts regarding usage of QNetworkAccessManager class-
    1) What I observed is that if I post to a valid URL I immediately get a response, but if the URL is invalid then it takes some time for the reply to come (sometimes like 40 secs).
    Moreover, if the URL is invalid then I observe an increase in memory usage in my application after the following line-
    Qt Code:
    1. m_networkManager->post(request,dataToBePosted);
    To copy to clipboard, switch view to plain text mode 
    I know this sounds very strange but this is what is happening. If the URL exists then everything is fine, but by mistake if I post to an invalid URL then my memory usage immediately shoots up

    2) In Qt Documentation it is mentioned that
    One QNetworkAccessManager should be enough for the whole Qt application.
    Suppose I use 2 QNetworkAccessManager objects in my application, will that create any issue?

    I would be really glad if someone would clarify my doubts.
    Last edited by sattu; 8th January 2014 at 15:39. Reason: Mistake in code

Similar Threads

  1. Job Posting - Software Developer (C++, Qt)
    By Cedric Matteo in forum Jobs
    Replies: 1
    Last Post: 26th October 2010, 13:25
  2. Posting data to QWebView
    By chrisb123 in forum Newbie
    Replies: 5
    Last Post: 29th October 2009, 06:58
  3. Posting a QKeyEvent to a QLineEdit
    By cocheci in forum Qt Programming
    Replies: 14
    Last Post: 5th June 2006, 14:54

Tags for this Thread

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.