ScummVM API documentation
Networking::NetworkReadStream Class Reference
Inheritance diagram for Networking::NetworkReadStream:
Common::ReadStream Common::Stream

Public Member Functions

 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)
 
 NetworkReadStream (const char *url, curl_slist *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
 
 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)
 
bool reuse (const char *url, curl_slist *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false)
 
bool reuse (const char *url, curl_slist *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles)
 
bool reuse (const char *url, curl_slist *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true)
 
bool eos () const override
 
uint32 read (void *dataPtr, uint32 dataSize) override
 
void finished (uint32 errorCode)
 
long httpResponseCode () const
 
Common::String currentLocation () const
 
Common::String responseHeaders () const
 
Common::HashMap< Common::String, Common::StringresponseHeadersMap () const
 
double getProgress () const
 
void setProgress (uint64 downloaded, uint64 total)
 
bool keepAlive () const
 
bool hasError () const
 
uint32 getErrorCode () const
 
const char * getError () const
 
- Public Member Functions inherited from Common::ReadStream
byte readByte ()
 
FORCEINLINE int8 readSByte ()
 
uint16 readUint16LE ()
 
uint32 readUint32LE ()
 
uint64 readUint64LE ()
 
uint16 readUint16BE ()
 
uint32 readUint32BE ()
 
uint64 readUint64BE ()
 
FORCEINLINE int16 readSint16LE ()
 
FORCEINLINE int32 readSint32LE ()
 
FORCEINLINE int64 readSint64LE ()
 
FORCEINLINE int16 readSint16BE ()
 
FORCEINLINE int32 readSint32BE ()
 
FORCEINLINE int64 readSint64BE ()
 
FORCEINLINE float readFloatLE ()
 
FORCEINLINE float readFloatBE ()
 
FORCEINLINE double readDoubleLE ()
 
FORCEINLINE double readDoubleBE ()
 
template<class TDataFormat , class... T>
bool readMultiple (const TDataFormat &dataFormat, T &...values)
 
template<class... T>
bool readMultipleEndian (bool isLittle, T &...values)
 
template<class... T>
bool readMultipleLE (T &...values)
 
template<class... T>
bool readMultipleBE (T &...values)
 
SeekableReadStreamreadStream (uint32 dataSize)
 
String readString (char terminator=0, size_t len=String::npos)
 
Common::String readPascalString (bool transformCR=true)
 
- Public Member Functions inherited from Common::Stream
virtual bool err () const
 
virtual void clearErr ()
 

Constructor & Destructor Documentation

◆ NetworkReadStream() [1/3]

Networking::NetworkReadStream::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 
)

Send <postFields>, using POST by default.

◆ NetworkReadStream() [2/3]

Networking::NetworkReadStream::NetworkReadStream ( const char *  url,
curl_slist *  headersList,
const Common::HashMap< Common::String, Common::String > &  formFields,
const Common::HashMap< Common::String, Common::Path > &  formFiles,
bool  keepAlive = false,
long  keepAliveIdle = 120,
long  keepAliveInterval = 60 
)

Send <formFields>, <formFiles>, using POST multipart/form.

◆ NetworkReadStream() [3/3]

Networking::NetworkReadStream::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 
)

Send <buffer>, using POST by default.

Member Function Documentation

◆ reuse() [1/3]

bool Networking::NetworkReadStream::reuse ( const char *  url,
curl_slist *  headersList,
const Common::String postFields,
bool  uploading = false,
bool  usingPatch = false 
)

Send <postFields>, using POST by default.

◆ reuse() [2/3]

bool Networking::NetworkReadStream::reuse ( const char *  url,
curl_slist *  headersList,
const Common::HashMap< Common::String, Common::String > &  formFields,
const Common::HashMap< Common::String, Common::Path > &  formFiles 
)

Send <formFields>, <formFiles>, using POST multipart/form.

◆ reuse() [3/3]

bool Networking::NetworkReadStream::reuse ( const char *  url,
curl_slist *  headersList,
const byte *  buffer,
uint32  bufferSize,
bool  uploading = false,
bool  usingPatch = false,
bool  post = true 
)

Send <buffer>, using POST by default.

◆ eos()

bool Networking::NetworkReadStream::eos ( ) const
overridevirtual

Returns true if a read failed because the stream end has been reached. This flag is cleared by clearErr(). For a SeekableReadStream, it is also cleared by a successful seek.

Note
The semantics of any implementation of this method are supposed to match those of ISO C feof(). In particular, in a stream with N bytes, reading exactly N bytes from the start should not set eos; only reading beyond the available data should set it.

Implements Common::ReadStream.

◆ read()

uint32 Networking::NetworkReadStream::read ( void *  dataPtr,
uint32  dataSize 
)
overridevirtual

Read data from the stream. Subclasses must implement this method; all other read methods are implemented using it.

Note
The semantics of any implementation of this method are supposed to match those of ISO C fread(), in particular where it concerns setting error and end of file/stream flags.
Parameters
dataPtrpointer to a buffer into which the data is read
dataSizenumber of bytes to be read
Returns
the number of bytes which were actually read.

Implements Common::ReadStream.

◆ finished()

void Networking::NetworkReadStream::finished ( uint32  errorCode)

This method is called by ConnectionManager to indicate that transfer is finished.

Note
It's called on failure too.

◆ httpResponseCode()

long Networking::NetworkReadStream::httpResponseCode ( ) const

Returns HTTP response code from inner CURL handle. It returns -1 to indicate there is no inner handle.

Note
This method should be called when eos() == true.

◆ currentLocation()

Common::String Networking::NetworkReadStream::currentLocation ( ) const

Return current location URL from inner CURL handle. "" is returned to indicate there is no inner handle.

Note
This method should be called when eos() == true.

◆ responseHeaders()

Common::String Networking::NetworkReadStream::responseHeaders ( ) const

Return response headers.

Note
This method should be called when eos() == true.

◆ responseHeadersMap()

Common::HashMap<Common::String, Common::String> Networking::NetworkReadStream::responseHeadersMap ( ) const

Return response headers as HashMap. All header names in it are lowercase.

Note
This method should be called when eos() == true.

◆ getProgress()

double Networking::NetworkReadStream::getProgress ( ) const

Returns a number in range [0, 1], where 1 is "complete".

◆ setProgress()

void Networking::NetworkReadStream::setProgress ( uint64  downloaded,
uint64  total 
)

Used in curl progress callback to pass current downloaded/total values.


The documentation for this class was generated from the following file: