Results 1 to 2 of 2

Thread: getUrl

  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default getUrl

    I use the following code to send a request to a server :
    Qt Code:
    1. int misc::getUrl( const QString & host, const QString & url, QHttp * pHttp, QIODevice * pDevice, const QString & referer )
    2. {
    3. qDebug( "getUrl host=%s url=%s", qPrintable( host ), qPrintable( url ) );
    4. Proxy p = proxy();
    5. if ( p.Enabled )
    6. pHttp->setProxy( p.Host, p.Port, p.Login, p.Password );
    7. pHttp->setHost( host );
    8. QHttpRequestHeader header( "GET", url, 1, 1 );
    9. header.setValue( "Host", host );
    10. if ( !referer.isEmpty() )
    11. header.setValue( "Referer", referer );
    12. header.setContentLength( 0 );
    13. return pHttp->request( header, 0, pDevice );
    14. }
    To copy to clipboard, switch view to plain text mode 


    It works very well, trouble is I cannot get the status result of the request that I expect to get through pDevice. I tried pDevice->data(), pDevice.readLine but nothing comes back. The request does what it should do but it won't tell me what it did.

    I assume this getUrl stuff is widespread (I got it from some friend), maybe you can tell me or hint at how I could get a status result !!

    No need to say that I am NOT an intermediate user, hardly a novice...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: getUrl

    You can use QHttp::lastResponse() to get hold of the last response object which contains the data you need.

  3. The following user says thank you to wysota for this useful post:

    incapacitant (21st April 2006)

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.