FastLED 3.10.8
Loading...
Searching...
No Matches

◆ parseChunkSize()

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

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

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

References fl::basic_string::c_str(), consume(), fl::adl_barrier::end(), fl::basic_string::find(), fl::FL_NO_EXCEPT, 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: