Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
ChunkedDecoder.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <functional>
4#include "framework_config.h"
6public:
7
8 void feed(const std::string& data, size_t maxLength = MAX_HTTP_BODY_LENGTH);
9
25 bool feedToFile(const std::string& data,
26 std::function<bool(const char* data, size_t len)> writeFn,
27 size_t maxLength = MAX_HTTP_BODY_LENGTH);
28
34 std::string getBuffer() const { return buffer; }
35
42 bool wasTruncated() const { return truncated; }
43 std::string getDecoded();
44 bool isComplete() const;
45
46private:
47 std::string buffer;
48 std::string decoded;
49 bool complete = false;
50 bool truncated = false;
51 size_t totalDecoded = 0;
52
53 void parseChunks(size_t maxLength);
54};
std::string buffer
std::string decoded
std::string getBuffer() const
Get the current buffer content.
void parseChunks(size_t maxLength)
void feed(const std::string &data, size_t maxLength=MAX_HTTP_BODY_LENGTH)
std::string getDecoded()
bool isComplete() const
bool wasTruncated() const
Set if the content-length is longer than the maximum value allowed.
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.
Delegates to user or system configuration.
#define MAX_HTTP_BODY_LENGTH
Maximum HTTP body size in bytes.