1

I'm using QNetworkAcessManager to download a pdf file from a direct link this the link here but it download nothing and the QByteArray size is 0 I try it on another link of mp3 files and many others and it works fine but I want to know why this link can't be downloaded I try using Curl to download it and the same problem so I try to do it in java but it give me an error

 Exception in thread "main" java.net.MalformedURLException: no protocol: www.proz.com/ht/profile_resources/022198_r4551c465d7a53.doc

when I search on this error the solve of it was to encode it so I back again and do it in Qt and encode the URL using this

//using QUrl To endcode the link
reply = manager->get(QNetworkRequest(QUrl(QUrl(Link).toEncoded())));
connect(reply, SIGNAL(readyRead()), this, SLOT(CollectFile()));
connect(reply, SIGNAL(finished()), this, SLOT(DocDownloaded()));

but the same problem for both java and Qt after encoded so what casue this problem and why it's not download any solution using QNetworkacessManager or using Curl
Update the url of the file i want to download

http://www.proz.com/ht/profile_resources/009424_r57075c01ae812.pdf

Thank in advance

user7179690
  • 1,051
  • 3
  • 17
  • 40
  • From the java error it looks as if your URL is missing a scheme. Can you edit your question to include the URL (or even just the result of [`QUrl::scheme`](http://doc.qt.io/qt-5/qurl.html#scheme))? – G.M. Apr 15 '17 at 17:56
  • Checking things out with `wget` suggests the URL is actually a redirect. Try setting the [`QNetworkRequest::FollowRedirectsAttribute`](http://doc.qt.io/qt-5/qnetworkrequest.html#Attribute-enum) attribute in the [`QNetworkRequest`](http://doc.qt.io/qt-5/qnetworkrequest.html#setAttribute) to see if that helps. – G.M. Apr 16 '17 at 07:55

2 Answers2

0

Have you tried to construct QNetworkRequest as:

 QNetworkRequest(QUrl(Link))

without 'toEncoded'?

According to example here, you need to use QUrl::fromEncoded to conscruct QUrl from encoded url, or simply skip all the manipulations.

Youw
  • 799
  • 6
  • 11
0

I solve the problem but because I have a little experience in web development I don't know why this happend
I solve it by when I download the file from normal web browser firefox or any or using Internet download manager application the Link is change
from :

http://www.proz.com/ht/profile_resources/009424_r57075c01ae812.pdf

to :

http://cdn3.proz.com/profile_resources/009424_r57075c01ae812.pdf

so when I copy the second link it can be downloaded now from my application or using Curl but don't know an explanation to that so if anyone can help and explain this why is this happened and the link change when I put it in internet download manager and give me the new link I will appreciate
this how i solve the problem but with no explain why this happened

user7179690
  • 1,051
  • 3
  • 17
  • 40
  • 1
    Right! Now it's clear: you didn't actually have a direct link. The first one redirects to another one. It's a known issue - redirection support just added lately. Check this post: http://stackoverflow.com/a/36386724/3697939 – Youw Apr 16 '17 at 21:13