HttpFetcher helper class for simple data fetch.
[yandex-traffic] / http_fetcher.hpp
diff --git a/http_fetcher.hpp b/http_fetcher.hpp
new file mode 100644 (file)
index 0000000..73a5528
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __HTTP_FETCHER_H__
+#define __HTTP_FETCHER_H__
+
+#include <QtCore>
+#include <QtNetwork>
+
+
+class HttpFetcher : public QObject
+{
+    Q_OBJECT
+private:
+    QHttp _http;
+    QBuffer _buffer;
+
+private slots:
+    void requestDone (bool err);
+
+signals:
+    void error (QHttp::Error error);
+    void done (const QByteArray& data);
+
+public:
+    HttpFetcher ();
+
+    bool busy () const;
+    void fetch (const QString& url);
+};
+
+
+#endif // __HTTP_FETCHER_H__