Results 1 to 4 of 4

Thread: demo project downloadmanager: result is '301 moved permanently' or zero byte file

  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  3. The following user says thank you to squidge for this useful post:

    JeanC (20th March 2011)

  4. #3
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: demo project downloadmanager: result is '301 moved permanently' or zero byte file

    Quote Originally Posted by squidge View Post
    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.

  5. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

Similar Threads

  1. Replies: 3
    Last Post: 3rd August 2010, 13:12
  2. Replies: 3
    Last Post: 19th April 2010, 14:16
  3. Read a Byte from Binary File
    By umulingu in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2010, 06:20
  4. Replies: 1
    Last Post: 3rd December 2009, 23:34
  5. Program result writed by qDebug() to file doesn't work.
    By Vincenzo in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 19:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.