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)
 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)
 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)
 Send <buffer, using POST by default.
virtual ~NetworkReadStream ()
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 ()
 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.
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.

Private Member Functions

void init (const char *url, curl_slist *headersList, const byte *buffer, uint32 bufferSize, bool uploading, bool usingPatch, bool post)
void init (const char *url, curl_slist *headersList, 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 _eos
bool _requestComplete
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 
)

Send <postFields>, using POST by default.

Definition at line 181 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 
)

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

Definition at line 186 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 
)

Send <buffer, using POST by default.

Definition at line 191 of file networkreadstream.cpp.

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

Definition at line 196 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 254 of file networkreadstream.cpp.

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

Definition at line 32 of file networkreadstream.cpp.

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

Definition at line 46 of file networkreadstream.cpp.

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

Definition at line 60 of file networkreadstream.cpp.

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

Definition at line 39 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 229 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 202 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 243 of file networkreadstream.cpp.

void Networking::NetworkReadStream::finished (  ) 

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

Note:
It's called on failure too.

Definition at line 218 of file networkreadstream.cpp.

double Networking::NetworkReadStream::getProgress (  )  const

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

Definition at line 259 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 222 of file networkreadstream.cpp.

void Networking::NetworkReadStream::init ( const char *  url,
curl_slist *  headersList,
Common::HashMap< Common::String, Common::String formFields,
Common::HashMap< Common::String, Common::String formFiles 
) [private]

Definition at line 117 of file networkreadstream.cpp.

void Networking::NetworkReadStream::init ( const char *  url,
curl_slist *  headersList,
const byte buffer,
uint32  bufferSize,
bool  uploading,
bool  usingPatch,
bool  post 
) [private]

Definition at line 65 of file networkreadstream.cpp.

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 206 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 239 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 265 of file networkreadstream.cpp.


Member Data Documentation

Definition at line 38 of file networkreadstream.h.

Definition at line 40 of file networkreadstream.h.

Definition at line 40 of file networkreadstream.h.


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


Generated on Sat Nov 9 2019 05:02:23 for ResidualVM by doxygen 1.7.1
curved edge   curved edge