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

Public Member Functions

virtual bool reuse (const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false)=0
 
virtual bool reuse (const char *url, RequestHeaders *headersList, const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles)=0
 
virtual bool reuse (const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true)=0
 
bool eos () const override
 
uint32 read (void *dataPtr, uint32 dataSize) override
 
virtual long httpResponseCode () const =0
 
virtual Common::String currentLocation () const =0
 
Common::String responseHeaders () const
 
virtual Common::HashMap< Common::String, Common::StringresponseHeadersMap () const =0
 
double getProgress () const
 
void setProgress (uint64 downloaded, uint64 total)
 
bool keepAlive () const
 
virtual bool hasError () const =0
 
virtual const char * getError () const =0
 
- 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 ()
 

Static Public Member Functions

static NetworkReadStreammake (const char *url, RequestHeaders *headersList, const Common::String &postFields, bool uploading=false, bool usingPatch=false, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
 
static NetworkReadStreammake (const char *url, RequestHeaders *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)
 
static NetworkReadStreammake (const char *url, RequestHeaders *headersList, const byte *buffer, uint32 bufferSize, bool uploading=false, bool usingPatch=false, bool post=true, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
 

Protected Member Functions

virtual void resetStream ()=0
 
virtual void setupBufferContents (const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post)=0
 
virtual void setupFormMultipart (const Common::HashMap< Common::String, Common::String > &formFields, const Common::HashMap< Common::String, Common::Path > &formFiles)=0
 
uint32 fillWithSendingContents (char *bufferToFill, uint32 maxSize)
 
uint32 addResponseHeaders (char *buffer, uint32 bufferSize)
 
 NetworkReadStream (bool keepAlive, long keepAliveIdle, long keepAliveInterval)
 

Protected Attributes

Common::MemoryReadWriteStream _backingStream
 
bool _keepAlive
 
long _keepAliveIdle
 
long _keepAliveInterval
 
bool _eos
 
bool _requestComplete
 
const byte * _sendingContentsBuffer
 
uint32 _sendingContentsSize
 
uint32 _sendingContentsPos
 
Common::String _responseHeaders
 
uint64 _progressDownloaded
 
uint64 _progressTotal
 

Member Function Documentation

◆ resetStream()

virtual void Networking::NetworkReadStream::resetStream ( )
protectedpure virtual

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

Note
It's called on failure too.

Implemented in Networking::NetworkReadStreamCurl.

◆ fillWithSendingContents()

uint32 Networking::NetworkReadStream::fillWithSendingContents ( char *  bufferToFill,
uint32  maxSize 
)
protected

Fills the passed buffer with _sendingContentsBuffer contents. It works similarly to read(), expect it's not for reading Stream's contents, but for sending our own data to the server.

Returns
how many bytes were actually read (filled in)

◆ addResponseHeaders()

uint32 Networking::NetworkReadStream::addResponseHeaders ( char *  buffer,
uint32  bufferSize 
)
protected

Remembers headers returned to CURL in server's response.

Returns
how many bytes were actually read

◆ make() [1/3]

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

Send <postFields>, using POST by default.

◆ make() [2/3]

static NetworkReadStream* Networking::NetworkReadStream::make ( const char *  url,
RequestHeaders 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 
)
static

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

◆ make() [3/3]

static NetworkReadStream* Networking::NetworkReadStream::make ( const char *  url,
RequestHeaders headersList,
const byte *  buffer,
uint32  bufferSize,
bool  uploading = false,
bool  usingPatch = false,
bool  post = true,
bool  keepAlive = false,
long  keepAliveIdle = 120,
long  keepAliveInterval = 60 
)
static

Send <buffer>, using POST by default.

◆ reuse() [1/3]

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

Send <postFields>, using POST by default.

Implemented in Networking::NetworkReadStreamCurl.

◆ reuse() [2/3]

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

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

Implemented in Networking::NetworkReadStreamCurl.

◆ reuse() [3/3]

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

Send <buffer>, using POST by default.

Implemented in Networking::NetworkReadStreamCurl.

◆ eos()

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

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.

◆ httpResponseCode()

virtual long Networking::NetworkReadStream::httpResponseCode ( ) const
pure virtual

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.

Implemented in Networking::NetworkReadStreamCurl.

◆ currentLocation()

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

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.

Implemented in Networking::NetworkReadStreamCurl.

◆ responseHeaders()

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

Return response headers.

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

◆ responseHeadersMap()

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

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

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

Implemented in Networking::NetworkReadStreamCurl.

◆ 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: