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

◆ writeChunk()

size_t fl::net::http::ChunkedWriter::writeChunk ( fl::span< const u8 > data,
fl::span< u8 > out )

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

187 {
188 // Format: <size-hex>\r\n<data>\r\n
189 char sizeHex[32];
190 int hexLen = fl::snprintf(sizeHex, sizeof(sizeHex), "%zx\r\n", data.size());
191 size_t totalNeeded = static_cast<size_t>(hexLen) + data.size() + 2;
192 if (out.size() < totalNeeded) {
193 return 0;
194 }
195
196 u8* dst = out.data();
197
198 // Write size hex + CRLF
199 memcpy(dst, sizeHex, static_cast<size_t>(hexLen));
200 dst += hexLen;
201
202 // Write data
203 memcpy(dst, data.data(), data.size());
204 dst += data.size();
205
206 // Write trailing CRLF
207 *dst++ = '\r';
208 *dst++ = '\n';
209
210 return totalNeeded;
211}
const T * data() const FL_NO_EXCEPT
Definition span.h:486
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
unsigned char u8
Definition stdint.h:131
int snprintf(char *buffer, fl::size size, const char *format) FL_NO_EXCEPT
FASTLED_FORCE_INLINE void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
Definition cstring.h:136

References fl::FL_NO_EXCEPT, fl::memcpy(), and fl::snprintf().

+ Here is the call graph for this function: