diff options
Diffstat (limited to 'backends/networking/curl/networkreadstream.h')
| -rw-r--r-- | backends/networking/curl/networkreadstream.h | 46 | 
1 files changed, 26 insertions, 20 deletions
diff --git a/backends/networking/curl/networkreadstream.h b/backends/networking/curl/networkreadstream.h index 8e59429a0a..c0ed5ee1c6 100644 --- a/backends/networking/curl/networkreadstream.h +++ b/backends/networking/curl/networkreadstream.h @@ -34,8 +34,9 @@ struct curl_slist;  namespace Networking { -class NetworkReadStream: public Common::MemoryReadWriteStream { +class NetworkReadStream: public Common::ReadStream {  	CURL *_easy; +	Common::MemoryReadWriteStream _backingStream;  	bool _eos, _requestComplete;  	const byte *_sendingContentsBuffer;  	uint32 _sendingContentsSize; @@ -46,6 +47,30 @@ class NetworkReadStream: public Common::MemoryReadWriteStream {  	void init(const char *url, curl_slist *headersList, const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post);  	void init(const char *url, curl_slist *headersList, Common::HashMap<Common::String, Common::String> formFields, Common::HashMap<Common::String, Common::String> formFiles); +	/** +	 * Fills the passed buffer with _sendingContentsBuffer contents. +	 * It works similarly to read(), expect it's not for reading +	 * Stream's contents, but for sending our own data to the server. +	 * +	 * @returns how many bytes were actually read (filled in) +	 */ +	uint32 fillWithSendingContents(char *bufferToFill, uint32 maxSize); + +	/** +	* Remembers headers returned to CURL in server's response. +	* +	* @returns how many bytes were actually read +	*/ +	uint32 addResponseHeaders(char *buffer, uint32 bufferSize); + +	/** Used in curl progress callback to pass current downloaded/total values. */ +	void setProgress(uint64 downloaded, uint64 total); + +	static size_t curlDataCallback(char *d, size_t n, size_t l, void *p); +	static size_t curlReadDataCallback(char *d, size_t n, size_t l, void *p); +	static size_t curlHeadersCallback(char *d, size_t n, size_t l, void *p); +	static int curlProgressCallback(void *p, long dltotal, long dlnow, long ultotal, long ulnow); +	static int curlProgressCallbackOlder(void *p, double dltotal, double dlnow, double ultotal, double ulnow);  public:  	/** Send <postFields>, using POST by default. */  	NetworkReadStream(const char *url, curl_slist *headersList, Common::String postFields, bool uploading = false, bool usingPatch = false); @@ -115,27 +140,8 @@ public:  	*/  	Common::String responseHeaders() const; -	/** -	 * Fills the passed buffer with _sendingContentsBuffer contents. -	 * It works similarly to read(), expect it's not for reading -	 * Stream's contents, but for sending our own data to the server. -	 * -	 * @returns how many bytes were actually read (filled in) -	 */ -	uint32 fillWithSendingContents(char *bufferToFill, uint32 maxSize); - -	/** -	* Remembers headers returned to CURL in server's response. -	* -	* @returns how many bytes were actually read -	*/ -	uint32 addResponseHeaders(char *buffer, uint32 bufferSize); -  	/** Returns a number in range [0, 1], where 1 is "complete". */  	double getProgress() const; - -	/** Used in curl progress callback to pass current downloaded/total values. */ -	void setProgress(uint64 downloaded, uint64 total);  };  } // End of namespace Networking  | 
