Fix various sample downloader issues especially server redirect handling

Thanks to Mike W9MDB for the concept  of forcing to HTTP if OpenSSL is
not installed or if the user requires it for other reasons.

The sample  downloader should  now be usable  with or  without OpenSSL
libraries being  installed, so long  as SourceForge continue  to serve
identical  content from  both HTTP  and  HTTPS schemes  on their  file
servers and mirrors.

For users with baulked  OpenSSL installations, incorrect or incomplete
CA  certificate  stores,  either  the improved  capability  to  ignore
SSL/TLS errors for  the duration of a session at  their discretion or,
as a last resort a new option to force an HTTP URL scheme is provided.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7379 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2016-12-11 21:19:31 +00:00
parent 41f213c44b
commit 8b1ef4d8be
7 changed files with 67 additions and 43 deletions
+9 -3
View File
@@ -6,6 +6,7 @@
#include <QUrl>
#include <QFileInfo>
#include <QSaveFile>
#include <QPointer>
class QNetworkAccessManager;
class QNetworkReply;
@@ -38,7 +39,8 @@ public:
};
explicit RemoteFile (ListenerInterface * listener, QNetworkAccessManager * network_manager
, QString const& local_file_path, QObject * parent = nullptr);
, QString const& local_file_path, bool http_only = false
, QObject * parent = nullptr);
// true if local file exists or will do very soon
bool local () const;
@@ -55,8 +57,11 @@ public:
QString local_file_path () const {return local_file_.absoluteFilePath ();}
QUrl url () const {return url_;}
// always use an http scheme for remote URLs
void http_only (bool flag = true) {http_only_ = flag;}
private:
void download (QUrl const& url);
void download (QUrl url);
void reply_finished ();
Q_SLOT void store ();
@@ -68,8 +73,9 @@ private:
ListenerInterface * listener_;
QNetworkAccessManager * network_manager_;
QFileInfo local_file_;
bool http_only_;
QUrl url_;
QNetworkReply * reply_;
QPointer<QNetworkReply> reply_;
bool is_valid_;
unsigned redirect_count_;
QSaveFile file_;