22 #ifndef BACKENDS_NETWORKING_HTTP_EMSCRIPTEN_NETWORKREADSTREAMEMSCRIPTEN_H 23 #define BACKENDS_NETWORKING_HTTP_EMSCRIPTEN_NETWORKREADSTREAMEMSCRIPTEN_H 27 #include "backends/networking/http/networkreadstream.h" 28 #include <emscripten/fetch.h> 32 class NetworkReadStream;
34 class NetworkReadStreamEmscripten :
public NetworkReadStream {
36 emscripten_fetch_attr_t *_emscripten_fetch_attr;
37 emscripten_fetch_t *_emscripten_fetch;
38 const char *_emscripten_fetch_url =
nullptr;
39 char **_emscripten_request_headers;
44 NetworkReadStreamEmscripten(
const char *url, RequestHeaders *headersList,
const Common::String &postFields,
bool uploading,
bool usingPatch,
bool keepAlive,
long keepAliveIdle,
long keepAliveInterval);
48 NetworkReadStreamEmscripten(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading,
bool usingPatch,
bool post,
bool keepAlive,
long keepAliveIdle,
long keepAliveInterval);
50 ~NetworkReadStreamEmscripten()
override;
51 void initEmscripten(
const char *url, RequestHeaders *headersList);
54 bool reuse(
const char *url, RequestHeaders *headersList,
const Common::String &postFields,
bool uploading =
false,
bool usingPatch =
false)
override {
return false; }
56 bool reuse(
const char *url, RequestHeaders *headersList,
const byte *buffer, uint32 bufferSize,
bool uploading =
false,
bool usingPatch =
false,
bool post =
false)
override {
return false; }
57 void setupBufferContents(
const byte *buffer, uint32 bufferSize,
bool uploading,
bool usingPatch,
bool post)
override;
60 bool hasError()
const override;
61 const char *getError()
const override;
63 long httpResponseCode()
const override;
66 void resetStream()
override;
68 uint32 read(
void *dataPtr, uint32 dataSize)
override;
71 static void emscriptenOnSuccess(emscripten_fetch_t *fetch);
72 static void emscriptenOnError(emscripten_fetch_t *fetch);
73 static void emscriptenOnProgress(emscripten_fetch_t *fetch);
74 static void emscriptenOnReadyStateChange(emscripten_fetch_t *fetch);
75 void emscriptenDownloadFinished(
bool success);
Definition: scummvmcloud.h:32