Why are you complicating things so much?This should work:
Qt Code:
int code = h.statusCode(); if(code>=300 && code<400 && h.hasKey("location")){ http->get(h.value("location")); return; } }To copy to clipboard, switch view to plain text mode
Why are you complicating things so much?This should work:
Qt Code:
int code = h.statusCode(); if(code>=300 && code<400 && h.hasKey("location")){ http->get(h.value("location")); return; } }To copy to clipboard, switch view to plain text mode
patrik08 (17th April 2007)
It should be case insensitive. If you're really interested, take a look at QHttpHeader sources and see if value() is case sensitive.
wysota, thank you, it makes the HTTP example run without error message, but the file will still not be downloaded. What else should I add to it for a correct download?
I can't say without knowing what's wrong. How do you handle the actual download?
Well, I just took the official HTTP example by Qt, and added your code to it:
Qt Code:
{ // handle redirections if (responseHeader.statusCode() >= 300 && responseHeader.statusCode() < 400 && responseHeader.hasKey("location")) { http->get(responseHeader.value("location")); return; } if (responseHeader.statusCode() != 200) //... }To copy to clipboard, switch view to plain text mode
But is that branch triggered for the redirected url or not?
Looks like that it gets to a redirection circle, i.e. site1 redirects to site2 which redirects to site1... I'm not sure how to work around this. Somehow it works only from browsers.
Sorry, I realized that there is a direct link:
http://easynews.dl.sourceforge.net/s...ges/source.zip
It works well with this link.
Bookmarks