Move response data handling to base class

This commit is contained in:
Tobias Taschner
2018-10-29 23:00:08 +01:00
parent 5660565081
commit 6530e3c08e
4 changed files with 72 additions and 55 deletions

View File

@@ -40,12 +40,12 @@ public:
State_Cancelled
};
enum Storage
{
Storage_Memory,
Storage_File,
Storage_None
};
enum Storage
{
Storage_Memory,
Storage_File,
Storage_None
};
virtual ~wxWebRequest() { }
@@ -60,8 +60,10 @@ public:
void SetIgnoreServerErrorStatus(bool ignore) { m_ignoreServerErrorStatus = ignore; }
virtual void SetStorage(Storage storage);
virtual void SetStorage(Storage storage) { m_storage = storage; }
Storage GetStorage() const { return m_storage; }
virtual void Start() = 0;
virtual void Cancel() = 0;
@@ -128,16 +130,27 @@ public:
virtual wxString GetStatusText() const = 0;
virtual wxInputStream* GetStream() const = 0;
virtual wxInputStream* GetStream() const;
virtual wxString GetSuggestedFileName() const;
virtual wxString AsString(wxMBConv* conv = NULL) const = 0;
wxString AsString(wxMBConv* conv = NULL) const;
protected:
wxWebResponse() { }
wxWebRequest& m_request;
size_t m_readSize;
wxWebResponse(wxWebRequest& request):
m_request(request), m_readSize(8 * 1024) { }
void* GetDataBuffer(size_t sizeNeeded);
void ReportDataReceived(size_t sizeReceived);
private:
wxMemoryBuffer m_readBuffer;
mutable wxScopedPtr<wxInputStream> m_stream;
wxDECLARE_NO_COPY_CLASS(wxWebResponse);
};