FastLED 3.9.15
Loading...
Searching...
No Matches

◆ parseChunkSize()

bool fl::net::http::ChunkedReader::parseChunkSize ( size_t & outSize)
private

Definition at line 125 of file chunked_encoding.cpp.hpp.

125 {
126 // Find CRLF in buffer
127 for (size_t i = 0; i + 1 < mBuffer.size(); i++) {
128 if (mBuffer[i] == '\r' && mBuffer[i + 1] == '\n') {
129 // Found CRLF, parse hex size
130 fl::string sizeStr(reinterpret_cast<const char*>(mBuffer.data()), i); // ok reinterpret cast
131
132 // Parse hex (ignore chunk extensions after ';')
133 size_t semicolon = sizeStr.find(';');
134 if (semicolon != fl::string::npos) {
135 sizeStr = sizeStr.substr(0, semicolon);
136 }
137
138 // Convert hex to size_t
139 char* end = nullptr;
140 outSize = static_cast<size_t>(strtoul(sizeStr.c_str(), &end, 16));
141 if (end == sizeStr.c_str()) {
142 // Invalid hex
143 return false;
144 }
145
146 // Consume size line + CRLF
147 consume(i + 2);
148 return true;
149 }
150 }
151 // No CRLF found
152 return false;
153}
static constexpr fl::size npos
Definition string.h:195
unsigned long strtoul(const char *str, char **endptr, int base)

References fl::basic_string::c_str(), consume(), fl::end(), fl::basic_string::find(), mBuffer, fl::string::npos, fl::strtoul(), and fl::string::substr().

Referenced by feed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: