31 #ifndef _gdownloader_h 32 #define _gdownloader_h 36 #include <QNetworkAccessManager> 37 #include <QNetworkReply> 81 string
getHeader(
const string& name)
const;
106 void httpGet(
const string& url);
121 void setHeader(
const string& name,
const string& value);
140 void downloadInternal();
141 void fileDownloadError(QNetworkReply::NetworkError);
142 void saveDownloadedData(
const string& member,
const string& filename =
"");
143 void sslErrors(QList<QSslError>);
144 void waitForDownload();
149 static string qtNetworkErrorToString(QNetworkReply::NetworkError nerror);
151 QNetworkAccessManager* _manager;
152 QNetworkReply* _reply;
153 std::map<string, string> _headers;
155 bool _downloadComplete;
159 string _lastErrorMessage;
164 #endif // _gdownloader_h int getHttpStatusCode() const
Returns the most recent HTTP status code, which may be a successful code (e.g.
Definition: gdownloader.cpp:130
A GDownloader can download files and data over an internet connection.
Definition: gdownloader.h:45
virtual ~GDownloader()
Frees memory allocated internally by the downloader.
Definition: gdownloader.cpp:42
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:143
bool hasError() const
Returns true if the HTTP connection failed and had an error.
Definition: gdownloader.cpp:147
void downloadToFile(string url, string file)
Downloads the text contents of the given URL, saving it to the given output file. ...
Definition: gdownloader.cpp:64
void setUserAgent(string userAgent)
Definition: gdownloader.cpp:232
void httpPost(string url)
Performs an HTTP POST request to the given URL, submitting any headers and query parameters previousl...
string getHeader(string name) const
Returns the value of the given HTTP header for this URL request.
Definition: gdownloader.cpp:135
string getErrorMessage() const
Returns the last HTTP error message that occurred.
Definition: gdownloader.cpp:126
GDownloader()
Creates a new downloader.
Definition: gdownloader.cpp:35
string downloadAsString(string url)
Downloads the text contents of the given URL, returning them as a string.
Definition: gdownloader.cpp:48
void httpGet(string url)
Performs an HTTP GET request to the given URL.
void setHeader(string name, string value)
Definition: gdownloader.cpp:228
void downloaded()
This Qt signal fires when the data is done downloading.