Results 1 to 4 of 4

Thread: http request

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default http request

    Hello,
    I am trying to connect to a webpage and save it as an html document.
    that code:

    Qt Code:
    1. QUrl url(finalLink);
    2. QString queryParttemp = finalLink;
    3. QString queryPart = queryParttemp.remove(url.host());
    4. queryPart.remove("http://");
    5. QHttpRequestHeader header("GET", queryPart);
    6. header.setValue("Host", url.host());
    7. httpInstance.request(header,0,&htmlFile);
    To copy to clipboard, switch view to plain text mode 

    usually works; but sometimes not..

    for example, a page from link:

    http://www.radikal.com.tr/default.as...ticleID=914625

    cannot be saved. I noticed something; when i enter this link on a web browser, the link automatically changes to:

    http://www.radikal.com.tr/Radikal.as...ticleID=914625

    Perhaps that is the reason why i cannot save the file..

    What should i do to save the result of that request(that html doc)?

    Thanks in advance...

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: http request

    Try using QNetworkAccessManager. It's much more flexible.
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: http request

    Hello Jpn,
    QNetworkAccessManager looks really good. But I have to use Qt4.3 for my embedded system. And this cIass was introduced in 4.4. Isn't there a good way to do that by using QHttp?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: http request

    Connect to signal QHttp::responseHeaderReceived(), check QHttpResponseHeader::statusCode() to see if it's 3xx, and get the redirect location with QHttpHeader::value("Location").
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    yagabey (29th December 2008)

Similar Threads

  1. A simple HTTP server going wrong.
    By spraff in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2008, 21:09
  2. QHTTP get request
    By s410i in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2008, 18:35
  3. uploading files to HTTP!!
    By Raajesh in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2008, 23:00
  4. X Error of failed request - on exit
    By VorosM in forum Newbie
    Replies: 3
    Last Post: 12th April 2006, 10:22
  5. http trouble again, segfaults when no internet
    By Bojan in forum Qt Programming
    Replies: 6
    Last Post: 18th January 2006, 21:25

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.