22 #ifndef BACKENDS_NETWORKING_CURL_NETWORKREADSTREAM_H 23 #define BACKENDS_NETWORKING_CURL_NETWORKREADSTREAM_H 25 #include "common/memstream.h" 26 #include "common/path.h" 27 #include "common/stream.h" 28 #include "common/str.h" 29 #include "common/hashmap.h" 30 #include "common/hash-str.h" 41 long _keepAliveIdle, _keepAliveInterval;
42 bool _eos, _requestComplete;
45 const byte *_sendingContentsBuffer;
46 uint32 _sendingContentsSize;
47 uint32 _sendingContentsPos;
50 uint64 _progressDownloaded, _progressTotal;
53 void initCurl(
const char *url, curl_slist *headersList);
54 bool reuseCurl(
const char *url, curl_slist *headersList);
55 void setupBufferContents(
const byte *buffer, uint32 bufferSize,
bool uploading,
bool usingPatch,
bool post);
65 uint32 fillWithSendingContents(
char *bufferToFill, uint32 maxSize);
72 uint32 addResponseHeaders(
char *buffer, uint32 bufferSize);
74 static size_t curlDataCallback(
char *d,
size_t n,
size_t l,
void *p);
75 static size_t curlReadDataCallback(
char *d,
size_t n,
size_t l,
void *p);
76 static size_t curlHeadersCallback(
char *d,
size_t n,
size_t l,
void *p);
77 static int curlProgressCallbackOlder(
void *p,
double dltotal,
double dlnow,
double ultotal,
double ulnow);
80 NetworkReadStream(
const char *url, curl_slist *headersList,
const Common::String &postFields,
bool uploading =
false,
bool usingPatch =
false,
bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
83 const char *url, curl_slist *headersList,
86 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
88 NetworkReadStream(
const char *url, curl_slist *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading =
false,
bool usingPatch =
false,
bool post =
true,
bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
92 bool reuse(
const char *url, curl_slist *headersList,
const Common::String &postFields,
bool uploading =
false,
bool usingPatch =
false);
95 const char *url, curl_slist *headersList,
99 bool reuse(
const char *url, curl_slist *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading =
false,
bool usingPatch =
false,
bool post =
true);
111 bool eos()
const override;
125 uint32
read(
void *dataPtr, uint32 dataSize)
override;
172 bool keepAlive()
const {
return _keepAlive; }
174 bool hasError()
const;
175 uint32 getErrorCode()
const {
return _errorCode; }
176 const char *getError()
const;
void setProgress(uint64 downloaded, uint64 total)
Common::HashMap< Common::String, Common::String > responseHeadersMap() const
Common::String currentLocation() const
Definition: scummvmcloud.h:31
bool eos() const override
void finished(uint32 errorCode)
double getProgress() const
Common::String responseHeaders() const
Definition: memstream.h:283
bool reuse(const char *url, curl_slist *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false)
Definition: networkreadstream.h:37
uint32 read(void *dataPtr, uint32 dataSize) override
long httpResponseCode() const
NetworkReadStream(const char *url, curl_slist *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)