3 #include "HttpHeader.h"
4 #include "HttpLineReader.h"
24 http_heaer_ptr = &header;
29 void open(
Client &client) {
30 LOGD(
"HttpChunkReader: %s",
"open");
36 virtual int read(Client &client, uint8_t *str,
int len) {
37 LOGD(
"HttpChunkReader: %s",
"read");
38 if (has_ended && open_chunk_len == 0)
return 0;
41 int read_max = len < open_chunk_len ? len : open_chunk_len;
42 int len_processed = client.read(str, read_max);
44 open_chunk_len -= len_processed;
47 if (open_chunk_len <= 0) {
56 virtual int readln(Client &client, uint8_t *str,
int len,
57 bool incl_nl =
true) {
58 LOGD(
"HttpChunkReader: %s",
"readln");
59 if (has_ended && open_chunk_len == 0)
return 0;
61 int read_max = len < open_chunk_len ? len : open_chunk_len;
62 int len_processed = readlnInternal(client, str, read_max, incl_nl);
63 open_chunk_len -= len_processed;
66 if (open_chunk_len <= 0) {
75 int result = has_ended ? 0 : open_chunk_len;
77 snprintf(msg, 50,
"available=>%d", result);
78 LOGD(
"HttpChunkReader: %s", msg);
85 bool has_ended =
false;
86 HttpReplyHeader *http_heaer_ptr;
88 void removeCRLF(Client &client) {
89 LOGD(
"HttpChunkReader: %s",
"removeCRLF");
91 if (client.peek() ==
'\r') {
92 LOGD(
"HttpChunkReader: %s",
"removeCR");
95 if (client.peek() ==
'\n') {
96 LOGD(
"HttpChunkReader: %s",
"removeLF");
102 virtual void readChunkLen(Client &client) {
103 LOGD(
"HttpChunkReader::readChunkLen");
105 readlnInternal(client, len_str, 50,
false);
106 LOGD(
"HttpChunkReader::readChunkLen %s", (
const char *)len_str);
107 open_chunk_len = strtol((
char *)len_str,
nullptr, 16);
110 snprintf(msg,40,
"chunk_len: %d", open_chunk_len);
111 LOGD(
"HttpChunkReader::readChunkLen->%s", msg);
113 if (open_chunk_len == 0) {
115 LOGD(
"HttpChunkReader::readChunkLen %s",
"last chunk received");
117 if (http_heaer_ptr !=
nullptr) {
118 http_heaer_ptr->readExt(client);