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;
66 : _backingStream(DisposeAfterUse::YES), _eos(
false), _requestComplete(
false), _sendingContentsBuffer(
nullptr),
67 _sendingContentsSize(0), _sendingContentsPos(0), _progressDownloaded(0), _progressTotal(0),
68 _keepAlive(keepAlive), _keepAliveIdle(keepAliveIdle), _keepAliveInterval(keepAliveInterval) {
76 bool uploading =
false,
bool usingPatch =
false,
77 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
82 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
85 static NetworkReadStream *
make(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
86 bool uploading =
false,
bool usingPatch =
false,
bool post =
true,
87 bool keepAlive =
false,
long keepAliveIdle = 120,
long keepAliveInterval = 60);
90 virtual bool reuse(
const char *url, RequestHeaders *headersList,
const Common::String &postFields,
bool uploading =
false,
bool usingPatch =
false) = 0;
93 const char *url, RequestHeaders *headersList,
97 virtual bool reuse(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading =
false,
bool usingPatch =
false,
bool post =
true) = 0;
108 bool eos()
const override {
return _eos; }
122 uint32
read(
void *dataPtr, uint32 dataSize)
override;
154 bool keepAlive()
const {
return _keepAlive; }
156 virtual bool hasError()
const = 0;
157 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:108
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
uint32 addResponseHeaders(char *buffer, uint32 bufferSize)
double getProgress() const
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