Wrong status code form QNetworkReply
I am using Qt Webkit to browse the internet and save the webpage to jpeg.
I use the following code to handle redirection situation.
@connect(m_page.networkAccessManager(), SIGNAL(finished(QNetworkReply )), this, SLOT(networkReplyFinished(QNetworkReply)));
void CWebkit::networkReplyFinished(QNetworkReply* reply)
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if( statusCode == 302)
// do something ...
When navigating this webpage: http://twitter.com/mashable. the statusCode should be 302(can be observed by using Google Chrome),
but Qt Webkit always give me 200, anyone knows what the problem is? thanks in advance.
andre last edited by
Are you sure that the problem is caused by Qt? Could you use wireshark or something like that to inspect the data you actually get from the webserver? It might be that the server is sending different responses to your application than it sends to your browser (for instance based on the broswer identification string).
I use "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;" as the User-Agent string.
i have used IE9 and Chrome15 and their own web development tools(press F12) to watch the network activities, the first responses are both 302 in the two browsers.
I will try wireshark to watch my applcation.
goetz last edited by
The redirect to https://twitter.com/#!/mashable happens only if you are logged in to twitter. If you are not logged in, it returns the HTML directly.
It may be that it's not directly related to being logged in, the redirect seems to happen too if you have been logged in and logged out again. Maybe a cookie issue. On a fresh installation of Camino, with no Twitter access so far, there is no redirection.
You can always check using a command line tool like curl.
I even do not have a twitter account ...
Using wireshark, i observed that sometimes the return code is 200 while sometimes is 302, can not find
the logic. but qt does return the right code to my application.
Another question (should i post a new thread to ask this?~~):
I mean do they happen in the same time?
goetz last edited by
Better ask in a new thread...