View Full Version : QHTTP get request

5th September 2008, 11:53

I'm trying to write a simple program for downloading pages. It works OK but only for some pages. For the other I'm getting an errors.I think that the GET request is too small, it contains to few informations. For instance the Qhttp GET request is:

GET / HTTP/1.1
Connection Keep-Alive
Host www.wrotamalopolski.pl

and the same but browsers request is:

GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/ Safari/525.13
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Cookie: ASP.NET_SessionId=hwasqe55zv... ble ble ble
Accept-Language: pl-PL,pl,en-US,en
Accept-Charset: ISO-8859-2,*,utf-8
Accept-Encoding: gzip,deflate,bzip2
If-Modified-Since: 128650639665900000
Host: www.wrotamalopolski.pl
Connection: Keep-Alive

And my question is if there are any functions to add User-Agent,Accept-Language etc. to the GET request in QHttp?

5th September 2008, 18:35
The problem certainly is not in Qt or handling the 302 response. As it is the server who sends weird answer, but what to expect from ASP.NET? Anyway, I've tried wireshark on that page and it appears that the website sent the same 302 response to the first Firefox request. So indeed it might depend on the optional request headers.

To add these headers, you have to set up the QHttpRequestHeader object and pass it to QHttp::request(). I would start with adding Accept-Language and Accept-Charset.