#include <reader.h>
Public Member Functions | |
Reader & | operator= (Reader &r) |
bool | readFirstHeaders () |
bool | readContent (Common::WriteStream *stream) |
bool | readFirstContent (Common::WriteStream *stream) |
bool | readBlockHeaders (Common::WriteStream *stream) |
bool | readBlockContent (Common::WriteStream *stream) |
void | setMode (ReaderMode mode) |
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 (const Common::String &name) const |
Common::String | anchor () const |
Static Public Member Functions | |
static Common::String | readEverythingFromMemoryStream (Common::MemoryReadWriteStream *stream) |
Static Public Attributes | |
static const int32 | SUSPICIOUS_HEADERS_SIZE = 1024 * 1024 |
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.