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

This is a helper class for Client. More...

#include <reader.h>

Collaboration diagram for Networking::Reader:

List of all members.

Public Member Functions

 Reader ()
 ~Reader ()
Readeroperator= (Reader &r)
bool readFirstHeaders ()
 public
bool readFirstContent (Common::WriteStream *stream)
bool readBlockHeaders (Common::WriteStream *stream)
bool readBlockContent (Common::WriteStream *stream)
void setContent (Common::MemoryReadWriteStream *stream)
bool badRequest () const
bool noMoreContent () const
Common::String headers () const
Common::String method () const
Common::String path () const
Common::String query () const
Common::String queryParameter (Common::String name) const
Common::String anchor () const

Static Public Member Functions

static Common::String readEverythingFromMemoryStream (Common::MemoryReadWriteStream *stream)

Static Public Attributes

static const uint32 SUSPICIOUS_HEADERS_SIZE = 1024 * 1024

Private Member Functions

void cleanup ()
bool readAndHandleFirstHeaders ()
bool readBlockHeadersIntoStream (Common::WriteStream *stream)
bool readContentIntoStream (Common::WriteStream *stream)
void handleFirstHeaders (Common::MemoryReadWriteStream *headers)
void parseFirstLine (const Common::String &headers)
void parsePathQueryAndAnchor (Common::String pathToParse)
void parseQueryParameters ()
void makeWindow (uint32 size)
void freeWindow ()
bool readOneByteInStream (Common::WriteStream *stream, const Common::String &boundary)
byte readOne ()
uint32 bytesLeft () const

Private Attributes

ReaderState _state
Common::MemoryReadWriteStream_content
uint32 _bytesLeft
byte_window
uint32 _windowUsed
uint32 _windowSize
Common::MemoryReadWriteStream_headersStream
Common::String _headers
Common::String _method
Common::String _path
Common::String _query
Common::String _anchor
Common::HashMap
< Common::String,
Common::String
_queryParameters
uint32 _contentLength
Common::String _boundary
uint32 _availableBytes
bool _firstBlock
bool _isBadRequest
bool _allContentRead

Detailed Description

This is a helper class for Client.

It parses HTTP request and finds headers and content. It also supports POST form/multipart.

One might pass the request even byte by byte, Reader will always be able to continue from the state it stopped on.

Main headers/content must be read with readFirstHeaders() and readFirstContent() methods. Further headers/content blocks (POST form/multipart) must be read with readBlockHeaders() and readBlockContent().

Main headers and parsed URL components could be accessed with special methods after reading.

To use the object, call setContent() and then one of those reading methods. It would return whether reading is over or not. If reading is over, content stream still could contain bytes to read with other methods.

If reading is not over, Reader awaits you to call the same reading method when you'd get more content.

If it's over, you should check whether Reader awaits more content with noMoreContent() and call the other reading method, if it is. When headers are read, one must read contents, and vice versa.

Definition at line 75 of file reader.h.


Constructor & Destructor Documentation

Networking::Reader::Reader (  ) 

Definition at line 31 of file reader.cpp.

Networking::Reader::~Reader (  ) 

Definition at line 49 of file reader.cpp.


Member Function Documentation

Common::String Networking::Reader::anchor (  )  const

Definition at line 447 of file reader.cpp.

bool Networking::Reader::badRequest (  )  const

Definition at line 433 of file reader.cpp.

uint32 Networking::Reader::bytesLeft (  )  const [private]

Definition at line 426 of file reader.cpp.

void Networking::Reader::cleanup (  )  [private]

Definition at line 87 of file reader.cpp.

void Networking::Reader::freeWindow (  )  [private]

Definition at line 313 of file reader.cpp.

void Networking::Reader::handleFirstHeaders ( Common::MemoryReadWriteStream headers  )  [private]

Definition at line 151 of file reader.cpp.

Common::String Networking::Reader::headers (  )  const

Definition at line 437 of file reader.cpp.

void Networking::Reader::makeWindow ( uint32  size  )  [private]

Definition at line 305 of file reader.cpp.

Common::String Networking::Reader::method (  )  const

Definition at line 439 of file reader.cpp.

bool Networking::Reader::noMoreContent (  )  const

Definition at line 435 of file reader.cpp.

Reader & Networking::Reader::operator= ( Reader r  ) 

Definition at line 53 of file reader.cpp.

void Networking::Reader::parseFirstLine ( const Common::String headers  )  [private]

Definition at line 172 of file reader.cpp.

void Networking::Reader::parsePathQueryAndAnchor ( Common::String  pathToParse  )  [private]

Definition at line 219 of file reader.cpp.

void Networking::Reader::parseQueryParameters (  )  [private]

Definition at line 248 of file reader.cpp.

Common::String Networking::Reader::path (  )  const

Definition at line 441 of file reader.cpp.

Common::String Networking::Reader::query (  )  const

Definition at line 443 of file reader.cpp.

Common::String Networking::Reader::queryParameter ( Common::String  name  )  const

Definition at line 445 of file reader.cpp.

bool Networking::Reader::readAndHandleFirstHeaders (  )  [private]

Definition at line 97 of file reader.cpp.

bool Networking::Reader::readBlockContent ( Common::WriteStream stream  ) 

Definition at line 398 of file reader.cpp.

bool Networking::Reader::readBlockHeaders ( Common::WriteStream stream  ) 

Definition at line 386 of file reader.cpp.

bool Networking::Reader::readBlockHeadersIntoStream ( Common::WriteStream stream  )  [private]

Definition at line 121 of file reader.cpp.

bool Networking::Reader::readContentIntoStream ( Common::WriteStream stream  )  [private]

Definition at line 282 of file reader.cpp.

Common::String Networking::Reader::readEverythingFromMemoryStream ( Common::MemoryReadWriteStream stream  )  [static]

Definition at line 449 of file reader.cpp.

bool Networking::Reader::readFirstContent ( Common::WriteStream stream  ) 

Definition at line 376 of file reader.cpp.

bool Networking::Reader::readFirstHeaders (  ) 

public

Definition at line 362 of file reader.cpp.

byte Networking::Reader::readOne (  )  [private]

Definition at line 352 of file reader.cpp.

bool Networking::Reader::readOneByteInStream ( Common::WriteStream stream,
const Common::String boundary 
) [private]

Definition at line 333 of file reader.cpp.

void Networking::Reader::setContent ( Common::MemoryReadWriteStream stream  ) 

Definition at line 428 of file reader.cpp.


Member Data Documentation

Definition at line 93 of file reader.h.

Definition at line 86 of file reader.h.

Definition at line 90 of file reader.h.

Definition at line 89 of file reader.h.

Definition at line 78 of file reader.h.

Definition at line 88 of file reader.h.

Definition at line 91 of file reader.h.

Definition at line 85 of file reader.h.

Definition at line 92 of file reader.h.

Definition at line 86 of file reader.h.

Definition at line 86 of file reader.h.

Definition at line 86 of file reader.h.

Definition at line 76 of file reader.h.

Definition at line 80 of file reader.h.

Definition at line 81 of file reader.h.

Definition at line 81 of file reader.h.

Definition at line 114 of file reader.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