#include <ChunkedDecoder.h>
Public Member Functions | |
void | feed (const std::string &data, size_t maxLength=MAX_HTTP_BODY_LENGTH) |
bool | feedToFile (const std::string &data, std::function< bool(const char *data, size_t len)> writeFn, size_t maxLength=MAX_HTTP_BODY_LENGTH) |
Feed data to the decoder, writing it to a file using the provided write function. | |
std::string | getBuffer () const |
Get the current buffer content. | |
bool | wasTruncated () const |
Set if the content-length is longer than the maximum value allowed. | |
std::string | getDecoded () |
bool | isComplete () const |
Private Member Functions | |
void | parseChunks (size_t maxLength) |
Private Attributes | |
std::string | buffer |
std::string | decoded |
bool | complete = false |
bool | truncated = false |
size_t | totalDecoded = 0 |
Definition at line 5 of file ChunkedDecoder.h.
void ChunkedDecoder::feed | ( | const std::string & | data, |
size_t | maxLength = MAX_HTTP_BODY_LENGTH |
||
) |
Definition at line 4 of file ChunkedDecoder.cpp.
References buffer, and parseChunks().
Referenced by HttpParser::receiveChunkedBodyToString().
bool ChunkedDecoder::feedToFile | ( | const std::string & | data, |
std::function< bool(const char *data, size_t len)> | writeFn, | ||
size_t | maxLength = MAX_HTTP_BODY_LENGTH |
||
) |
This function will write the data to a file using the provided write function. If the data exceeds maxLength, it will be truncated and truncated flag will be set.
data | The data to feed to the decoder. |
writeFn | The function to write data to a file. |
maxLength | The maximum length of data to process (default is MAX_HTTP_BODY_LENGTH). |
Definition at line 9 of file ChunkedDecoder.cpp.
References buffer, complete, totalDecoded, and truncated.
Referenced by HttpParser::receiveChunkedBodyToFile().
|
inline |
This returns the raw buffer content that has been fed to the decoder.
Definition at line 34 of file ChunkedDecoder.h.
References buffer.
std::string ChunkedDecoder::getDecoded | ( | ) |
Definition at line 63 of file ChunkedDecoder.cpp.
References decoded.
Referenced by HttpParser::receiveChunkedBodyToString().
bool ChunkedDecoder::isComplete | ( | ) | const |
Definition at line 67 of file ChunkedDecoder.cpp.
References complete.
Referenced by HttpParser::receiveChunkedBodyToFile(), and HttpParser::receiveChunkedBodyToString().
|
private |
Definition at line 71 of file ChunkedDecoder.cpp.
References buffer, complete, decoded, and truncated.
Referenced by feed().
|
inline |
This checks if the decoder has processed all chunks and is ready to return the decoded data.
Definition at line 42 of file ChunkedDecoder.h.
References truncated.
Referenced by HttpParser::receiveChunkedBodyToFile(), and HttpParser::receiveChunkedBodyToString().
|
private |
Definition at line 47 of file ChunkedDecoder.h.
Referenced by feed(), feedToFile(), getBuffer(), and parseChunks().
|
private |
Definition at line 49 of file ChunkedDecoder.h.
Referenced by feedToFile(), isComplete(), and parseChunks().
|
private |
Definition at line 48 of file ChunkedDecoder.h.
Referenced by getDecoded(), and parseChunks().
|
private |
Definition at line 51 of file ChunkedDecoder.h.
Referenced by feedToFile().
|
private |
Definition at line 50 of file ChunkedDecoder.h.
Referenced by feedToFile(), parseChunks(), and wasTruncated().