MCPcopy Create free account
hub / github.com/FastLED/FastLED / parseChunkSize

Method parseChunkSize

src/fl/net/http/chunked_encoding.cpp.hpp:125–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125bool ChunkedReader::parseChunkSize(size_t& outSize) {
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}
154
155bool ChunkedReader::hasCRLF() const {
156 return mBuffer.size() >= 2 && mBuffer[0] == '\r' && mBuffer[1] == '\n';

Callers

nothing calls this directly

Calls 6

strtoulFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected