1 #ifndef CHTTP_H 2 #define CHTTP_H 3 4 #include "http.h" 5 #include <QtNetwork> 6 7 #include "sharedcache.h" 8 9 class SharedCacheHttp : public Http { 10 public: 11 SharedCacheHttp(Http &http = Http::instance()); 12 HttpReply *request(const HttpRequest &req); 13 14 void setBaseUrl(const QString &url); getBaseUrl()15 const QString &getBaseUrl() { return baseUrl; } 16 17 void setGroup(const QString &name); getGroup()18 const QString &getGroup() { return group; } 19 setCacheEmptyReplies(bool value)20 void setCacheEmptyReplies(bool value) { cacheEmptyReplies = value; } getCacheEmptyReplies()21 bool getCacheEmptyReplies() { return cacheEmptyReplies; } 22 getSharedCache()23 SharedCache &getSharedCache() { return sharedCache; } 24 25 private: 26 SharedCache sharedCache; 27 Http &http; 28 QString group; 29 QString baseUrl; 30 bool cacheEmptyReplies; 31 }; 32 33 class SharedCacheHttpReply : public HttpReply { 34 Q_OBJECT 35 36 public: 37 SharedCacheHttpReply(SharedCacheHttp &chttp, Http &http, const HttpRequest &req); 38 url()39 QUrl url() const { return QUrl(); } statusCode()40 int statusCode() const { return -1; } body()41 QByteArray body() const { return QByteArray(); } 42 43 signals: 44 void data(const QByteArray &bytes); 45 void error(QString message); 46 void finished(const HttpReply &reply); 47 48 private: 49 SharedCacheHttp &chttp; 50 Http &http; 51 HttpRequest req; 52 QString hash; 53 }; 54 55 #endif // CHTTP_H 56