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

Method writeResponse

src/fl/net/http/stream_transport.cpp.hpp:291–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291void HttpStreamTransport::writeResponse(const fl::json& response) {
292 if (!isConnected()) {
293 return;
294 }
295
296 // Serialize JSON to string
297 fl::string jsonStr = response.to_string();
298
299 // Write chunked data into stack buffer (or heap for large payloads)
300 size_t needed = ChunkedWriter::chunkOverhead(jsonStr.size());
301 u8 stackBuf[512];
302 fl::vector<u8> heapBuf;
303 fl::span<u8> outSpan;
304 if (needed <= sizeof(stackBuf)) {
305 outSpan = fl::span<u8>(stackBuf, sizeof(stackBuf));
306 } else {
307 heapBuf.resize(needed);
308 outSpan = heapBuf;
309 }
310 size_t written = mWriter.writeChunk(
311 fl::span<const u8>(reinterpret_cast<const u8*>(jsonStr.c_str()), jsonStr.size()), // ok reinterpret cast
312 outSpan
313 );
314
315 // Send chunked data
316 if (written > 0) {
317 sendData(fl::span<const u8>(outSpan.data(), written));
318 }
319
320 // Update last sent time
321 mLastHeartbeatSent = getCurrentTimeMs();
322}
323
324void HttpStreamTransport::update(u32 currentTimeMs) {
325 // Update connection state

Callers 8

FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80
FL_TEST_FILEFunction · 0.80

Calls 6

writeChunkMethod · 0.80
to_stringMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
c_strMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected