demo project downloadmanager: result is '301 moved permanently' or zero byte file
Hello,
I'm trying the 'network download' demo project .
The url I give it is valid, it's something like "http://nzbmatrix.com/api-nzb-download.php?id=1234&username=xx&apikey=yy"
Unfortunately I can't give the exact url because it contains my inlog data.
I don't get the file though, I get a file with a redirect message. When I enter the url in the browser it downloads.
Something similar happens when I try to download a file from my own website, url = "http://www.jcremers.com/dl.php?file=SetupPlanetdance4.0.exe"
It downloads a 0 byte file.
How is this done?
Thanks.
Re: demo project downloadmanager: result is '301 moved permanently' or zero byte file
A web browser would download the redirect message and then goto the address indicated in the redirect. I don't think the demo projects support such requests. A redirection can be detected by looking for a http response code 3xx.
Re: demo project downloadmanager: result is '301 moved permanently' or zero byte file
Quote:
Originally Posted by
squidge
A web browser would download the redirect message and then goto the address indicated in the redirect. I don't think the demo projects support such requests. A redirection can be detected by looking for a http response code 3xx.
Yes that's what I'm doing now, looking for "<title>301 Moved Permanently</title>".
Thanks.
Re: demo project downloadmanager: result is '301 moved permanently' or zero byte file
A better way would be to get the code from the reply like reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) and then use reply->attribute(QNetworkRequest::RedirectionTargetAttribute)
Actually, In fact, if RedirectionTargetAttribute is present, you know it's a redirect, as theres no reason for it to be set otherwise.