ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

#include <networkreadstream.h>

Inheritance diagram for Networking::NetworkReadStream:
Collaboration diagram for Networking::NetworkReadStream:

List of all members.

Public Member Functions

 NetworkReadStream (const char *url, curl_slist *headersList, 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 (const char *url, curl_slist *headersList, Common::HashMap< Common::String, Common::String > formFields, Common::HashMap< Common::String, Common::String > formFiles, bool keepAlive=false, long keepAliveIdle=120, long keepAliveInterval=60)
 Send <formFields>, <formFiles>, using POST multipart/form.
 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.
virtual ~NetworkReadStream ()
bool reuse (const char *url, curl_slist *headersList, Common::String postFields, bool uploading=false, bool usingPatch=false)
 Send <postFields>, using POST by default.
bool reuse (const char *url, curl_slist *headersList, Common::HashMap< Common::String, Common::String > formFields, Common::HashMap< Common::String, Common::String > formFiles)
 Send <formFields>, <formFiles>, using POST multipart/form.
bool 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.
virtual bool eos () const
 Returns true if a read failed because the stream end has been reached.
virtual uint32 read (void *dataPtr, uint32 dataSize)
 Read data from the stream.
void finished (uint32 errorCode)
 This method is called by ConnectionManager to indicate that transfer is finished.
long httpResponseCode () const
 Returns HTTP response code from inner CURL handle.
Common::String currentLocation () const
 Return current location URL from inner CURL handle.
Common::String responseHeaders () const
 Return response headers.
Common::HashMap
< Common::String,
Common::String
responseHeadersMap () const
 Return response headers as HashMap.
double getProgress () const
 Returns a number in range [0, 1], where 1 is "complete".
void setProgress (uint64 downloaded, uint64 total)
 Used in curl progress callback to pass current downloaded/total values.
bool keepAlive () const

Private Member Functions

void resetStream ()
void initCurl (const char *url, curl_slist *headersList)
bool reuseCurl (const char *url, curl_slist *headersList)
void setupBufferContents (const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post)
void setupFormMultipart (Common::HashMap< Common::String, Common::String > formFields, Common::HashMap< Common::String, Common::String > formFiles)
uint32 fillWithSendingContents (char *bufferToFill, uint32 maxSize)
 Fills the passed buffer with _sendingContentsBuffer contents.
uint32 addResponseHeaders (char *buffer, uint32 bufferSize)
 Remembers headers returned to CURL in server's response.

Static Private Member Functions

static size_t curlDataCallback (char *d, size_t n, size_t l, void *p)
static size_t curlReadDataCallback (char *d, size_t n, size_t l, void *p)
static size_t curlHeadersCallback (char *d, size_t n, size_t l, void *p)
static int curlProgressCallbackOlder (void *p, double dltotal, double dlnow, double ultotal, double ulnow)

Private Attributes

CURL_easy
Common::MemoryReadWriteStream _backingStream
bool _keepAlive
long _keepAliveIdle
long _keepAliveInterval
bool _eos
bool _requestComplete
char * _errorBuffer
const byte_sendingContentsBuffer
uint32 _sendingContentsSize
uint32 _sendingContentsPos
byte_bufferCopy
Common::String _responseHeaders
uint64 _progressDownloaded
uint64 _progressTotal

Detailed Description

Definition at line 37 of file networkreadstream.h.


Constructor & Destructor Documentation

Networking::NetworkReadStream::NetworkReadStream ( const char *  url,
curl_slist *  headersList,
Common::String  postFields,
bool  uploading = false,
bool  usingPatch = false,
bool  keepAlive = false,
long  keepAliveIdle = 120,
long  keepAliveInterval = 60 
)

Send <postFields>, using POST by default.

Definition at line 196 of file networkreadstream.cpp.

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

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

Definition at line 202 of file networkreadstream.cpp.

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.

Definition at line 208 of file networkreadstream.cpp.

Networking::NetworkReadStream::~NetworkReadStream (  )  [virtual]

Definition at line 241 of file networkreadstream.cpp.


Member Function Documentation

uint32 Networking::NetworkReadStream::addResponseHeaders ( char *  buffer,
uint32  bufferSize 
) [private]

Remembers headers returned to CURL in server's response.

Returns:
how many bytes were actually read

Definition at line 382 of file networkreadstream.cpp.

size_t Networking::NetworkReadStream::curlDataCallback ( char *  d,
size_t  n,
size_t  l,
void *  p 
) [static, private]

Definition at line 33 of file networkreadstream.cpp.

size_t Networking::NetworkReadStream::curlHeadersCallback ( char *  d,
size_t  n,
size_t  l,
void *  p 
) [static, private]

Definition at line 47 of file networkreadstream.cpp.

int Networking::NetworkReadStream::curlProgressCallbackOlder ( void *  p,
double  dltotal,
double  dlnow,
double  ultotal,
double  ulnow 
) [static, private]

Definition at line 61 of file networkreadstream.cpp.

size_t Networking::NetworkReadStream::curlReadDataCallback ( char *  d,
size_t  n,
size_t  l,
void *  p 
) [static, private]

Definition at line 40 of file networkreadstream.cpp.

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.

Definition at line 285 of file networkreadstream.cpp.

bool Networking::NetworkReadStream::eos (  )  const [virtual]

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.

Definition at line 248 of file networkreadstream.cpp.

uint32 Networking::NetworkReadStream::fillWithSendingContents ( char *  bufferToFill,
uint32  maxSize 
) [private]

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)

Definition at line 371 of file networkreadstream.cpp.

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.

Definition at line 264 of file networkreadstream.cpp.

double Networking::NetworkReadStream::getProgress (  )  const

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

Definition at line 387 of file networkreadstream.cpp.

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.

Definition at line 278 of file networkreadstream.cpp.

void Networking::NetworkReadStream::initCurl ( const char *  url,
curl_slist *  headersList 
) [private]

Definition at line 76 of file networkreadstream.cpp.

bool Networking::NetworkReadStream::keepAlive (  )  const [inline]

Definition at line 171 of file networkreadstream.h.

uint32 Networking::NetworkReadStream::read ( void *  dataPtr,
uint32  dataSize 
) [virtual]

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:
dataPtr pointer to a buffer into which the data is read
dataSize number of bytes to be read
Returns:
the number of bytes which were actually read.

Implements Common::ReadStream.

Definition at line 252 of file networkreadstream.cpp.

void Networking::NetworkReadStream::resetStream (  )  [private]

Definition at line 66 of file networkreadstream.cpp.

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

Return response headers.

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

Definition at line 295 of file networkreadstream.cpp.

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.

Definition at line 299 of file networkreadstream.cpp.

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

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

Definition at line 223 of file networkreadstream.cpp.

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.

Definition at line 232 of file networkreadstream.cpp.

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

Send <postFields>, using POST by default.

Definition at line 214 of file networkreadstream.cpp.

bool Networking::NetworkReadStream::reuseCurl ( const char *  url,
curl_slist *  headersList 
) [private]

Definition at line 121 of file networkreadstream.cpp.

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

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

Definition at line 393 of file networkreadstream.cpp.

void Networking::NetworkReadStream::setupBufferContents ( const byte buffer,
uint32  bufferSize,
bool  uploading,
bool  usingPatch,
bool  post 
) [private]

Definition at line 136 of file networkreadstream.cpp.

void Networking::NetworkReadStream::setupFormMultipart ( Common::HashMap< Common::String, Common::String formFields,
Common::HashMap< Common::String, Common::String formFiles 
) [private]

Definition at line 161 of file networkreadstream.cpp.


Member Data Documentation

Definition at line 38 of file networkreadstream.h.

Definition at line 42 of file networkreadstream.h.

Definition at line 43 of file networkreadstream.h.

Definition at line 40 of file networkreadstream.h.

Definition at line 41 of file networkreadstream.h.

Definition at line 41 of file networkreadstream.h.

Definition at line 42 of file networkreadstream.h.


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


Generated on Sat May 30 2020 05:03:33 for ResidualVM by doxygen 1.7.1
curved edge   curved edge