22 #ifndef BACKENDS_NETWORKING_HTTP_NETWORKREADSTREAM_H 23 #define BACKENDS_NETWORKING_HTTP_NETWORKREADSTREAM_H 25 #include "common/array.h" 26 #include "common/hash-str.h" 27 #include "common/hashmap.h" 28 #include "common/memstream.h" 29 #include "common/path.h" 30 #include "common/str.h" 31 #include "common/stream.h" 41 long _keepAliveIdle, _keepAliveInterval;
42 bool _eos, _requestComplete;
43 const byte *_sendingContentsBuffer;
44 uint32 _sendingContentsSize;
45 uint32 _sendingContentsPos;
47 uint64 _progressDownloaded, _progressTotal;
57 virtual void setupBufferContents(
const byte *buffer, uint32 bufferSize,
bool uploading,
bool usingPatch,
bool post) = 0;
77 : _backingStream(DisposeAfterUse::YES), _eos(
false), _requestComplete(
false), _sendingContentsBuffer(
nullptr),
78 _sendingContentsSize(0), _sendingContentsPos(0), _progressDownloaded(0), _progressTotal(0),
79 _keepAlive(keepAlive), _keepAliveIdle(keepAliveIdle), _keepAliveInterval(keepAliveInterval) {
87 bool uploading =
false,
bool usingPatch =
false,
88 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
93 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
96 static NetworkReadStream *
make(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
97 bool uploading =
false,
bool usingPatch =
false,
bool post =
true,
98 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
101 virtual bool reuse(
const char *url, RequestHeaders *headersList,
const Common::String &postFields,
bool uploading =
false,
bool usingPatch =
false) = 0;
104 const char *url, RequestHeaders *headersList,
108 virtual bool reuse(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading =
false,
bool usingPatch =
false,
bool post =
true) = 0;
119 bool eos()
const override {
return _eos; }
133 uint32
read(
void *dataPtr, uint32 dataSize)
override;
157 return _responseHeaders;
174 bool keepAlive()
const {
return _keepAlive; }
176 virtual bool hasError()
const = 0;
177 virtual const char *getError()
const = 0;
virtual Common::HashMap< Common::String, Common::String > responseHeadersMap() const =0
void setProgress(uint64 downloaded, uint64 total)
virtual bool reuse(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false)=0
Definition: scummvmcloud.h:32
bool eos() const override
Definition: networkreadstream.h:119
static NetworkReadStream * make(const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
virtual long httpResponseCode() const =0
virtual void resetStream()=0
uint32 addResponseHeaders(char *buffer, uint32 bufferSize)
double getProgress() const
Common::String responseHeaders() const
Definition: networkreadstream.h:156
Definition: memstream.h:283
uint32 fillWithSendingContents(char *bufferToFill, uint32 maxSize)
Definition: networkreadstream.h:37
uint32 read(void *dataPtr, uint32 dataSize) override
virtual Common::String currentLocation() const =0