PDA

View Full Version : http request



yagabey
28th December 2008, 01:01
Hello,
I am trying to connect to a webpage and save it as an html document.
that code:


QUrl url(finalLink);
QString queryParttemp = finalLink;
QString queryPart = queryParttemp.remove(url.host());
queryPart.remove("http://");
QHttpRequestHeader header("GET", queryPart);
header.setValue("Host", url.host());
httpInstance.request(header,0,&htmlFile);

usually works; but sometimes not..

for example, a page from link:

http://www.radikal.com.tr/default.aspx?aType=HaberDetay&ArticleID=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.aspx?aType=RadikalHaberDetay&ArticleID=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...

jpn
28th December 2008, 13:20
Try using QNetworkAccessManager. It's much more flexible.

yagabey
28th December 2008, 18:15
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?

jpn
28th December 2008, 19:19
Connect to signal QHttp::responseHeaderReceived(), check QHttpResponseHeader::statusCode() to see if it's 3xx, and get the redirect location with QHttpHeader::value("Location").