30 #ifndef _gdownloader_h 31 #define _gdownloader_h 35 #include <QNetworkAccessManager> 36 #include <QNetworkReply> 78 string
getHeader(
const string& name)
const;
103 void httpGet(
const string& url);
118 void setHeader(
const string& name,
const string& value);
137 void downloadInternal();
138 void fileDownloadError(QNetworkReply::NetworkError);
139 void saveDownloadedData(
const string& member,
const string& filename =
"");
140 void sslErrors(QList<QSslError>);
141 void waitForDownload();
146 static string qtNetworkErrorToString(QNetworkReply::NetworkError nerror);
148 QNetworkAccessManager* _manager;
149 QNetworkReply* _reply;
150 std::map<string, string> _headers;
152 bool _downloadComplete;
156 string _lastErrorMessage;
159 #endif // _gdownloader_h virtual ~GDownloader()
Frees memory allocated internally by the downloader.
Definition: gdownloader.cpp:38
A GDownloader can download files and data over an internet connection.
Definition: gdownloader.h:42
string downloadAsString(string url)
Downloads the text contents of the given URL, returning them as a string.
Definition: gdownloader.cpp:44
string getUserAgent() const
Returns the value of the HTTP "User-Agent" header for this URL request, or an empty string if the use...
Definition: gdownloader.cpp:139
void setHeader(string name, string value)
Definition: gdownloader.cpp:224
void httpGet(string url)
Performs an HTTP GET request to the given URL.
string getHeader(string name) const
Returns the value of the given HTTP header for this URL request.
Definition: gdownloader.cpp:131
string getErrorMessage() const
Returns the last HTTP error message that occurred.
Definition: gdownloader.cpp:122
void downloaded()
This Qt signal fires when the data is done downloading.
GDownloader()
Creates a new downloader.
Definition: gdownloader.cpp:31
int getHttpStatusCode() const
Returns the most recent HTTP status code, which may be a successful code (e.g.
Definition: gdownloader.cpp:126
bool hasError() const
Returns true if the HTTP connection failed and had an error.
Definition: gdownloader.cpp:143
void httpPost(string url)
Performs an HTTP POST request to the given URL, submitting any headers and query parameters previousl...
void downloadToFile(string url, string file)
Downloads the text contents of the given URL, saving it to the given output file. ...
Definition: gdownloader.cpp:60
void setUserAgent(string userAgent)
Definition: gdownloader.cpp:228