The HTTP example fails at this URL:
http://downloads.sourceforge.net/isisimages/source.zip
How to make it work?
Printable View
The HTTP example fails at this URL:
http://downloads.sourceforge.net/isisimages/source.zip
How to make it work?
The link is being redirected to here :
http://sourceforge.net/project/downl...se_mirror=kent
On sourceforge I think you're always being redirected to a random mirror.
Maybe you could find out somehow to which mirror you're being redirected.
regards
Read the header location.... from first url and grab the next url ....
on your case
QString QHttpHeader::value ("Location")
return the new url or path...
sample read ....
depend on ip client ... grab the next url mirror....
Code:
{ ActualCook.clear(); for (int i = 0; i < cookielist.size(); ++i) { /////////////////qDebug() << "### entry set-cookie pos=" << i << " name= " << cookiename << " value=" << Url_Decode(cookievalue); } //////////emit WatReturn(QString("One code=%1 - Other say = %2 \n%3").arg( responseHeader.statusCode() ).arg( responseHeader.reasonPhrase() ).arg(CookieVars()) ); }
discovery on http://livehttpheaders.mozdev.org/
Code:
http://downloads.sourceforge.net/isisimages/source.zip GET /isisimages/source.zip HTTP/1.1 Host: downloads.sourceforge.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.qtcentre.org/forum//forum/newreply.php?do=postreply&t=6595 Cookie: ebNewBandWidth_.sourceforge.net=589%3A1175362503265; __utmz=191645736.1176795478.834.46.utmccn=(referral)|utmcsr=qtcentre.org|utmcct=/forum/f-qt-programming-2/t-how-to-make-qhttp-work-with-this-url-6595.html|utmcmd=referral; username=gasSKXJewRo%3D; __utma=191645736.346796218.1169658266.1176747181.1176795478.834; sso_session_ser=yKK3e8LVW6r8auGwiHUNePItpalud5j%2B54olwzSzS4soMkSBvWa4R%2BJEPm6Wn30sQiHC17XThHPg3KMsC2qEPizzVh%2FYdN2K0Ec75%2FtfH%2B8mVoAtmF0bDYklJOqyuyLa%2B4%2BQqU5aYeW2GfRW%2FqCBbnKjYuiyNGIdc0g5ydI5sBQ%3D-5ead3f2617584e562295ee6a3be43f78; __utmc=191645736; __utmb=191645736 HTTP/1.x 301 Moved Permanently X-Powered-By: PHP/5.2.1 Location: http://sourceforge.net/project/downloading.php?groupname=isisimages&filename=source.zip&use_mirror=heanet Content-Type: text/html Content-Length: 0 Date: Tue, 17 Apr 2007 07:54:32 GMT Server: lighttpd/1.4.15 ----------------------------------------------------------
Why are you complicating things so much? :) This should work:
Code:
int code = h.statusCode(); if(code>=300 && code<400 && h.hasKey("location")){ http->get(h.value("location")); return; } }
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:
Code:
{ // handle redirections if (responseHeader.statusCode() >= 300 && responseHeader.statusCode() < 400 && responseHeader.hasKey("location")) { http->get(responseHeader.value("location")); return; } if (responseHeader.statusCode() != 200) //... }
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.