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

Method sendHttpResponseHeader

src/fl/net/http/stream_server.cpp.hpp:253–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253bool HttpStreamServer::sendHttpResponseHeader(u32 clientId) {
254 ClientState* state = getOrCreateClientState(clientId);
255 if (!state) {
256 return false;
257 }
258
259 if (state->httpHeaderSent) {
260 return true; // Already sent
261 }
262
263 // Build HTTP 200 OK response header
264 fl::string header;
265 header.append("HTTP/1.1 200 OK\r\n");
266 header.append("Content-Type: application/json\r\n");
267 header.append("Transfer-Encoding: chunked\r\n");
268 header.append("Connection: keep-alive\r\n");
269 header.append("\r\n");
270
271 // Send header
272 int sent = mNativeServer->send(clientId, fl::span<const u8>(reinterpret_cast<const u8*>(header.c_str()), header.size())); // ok reinterpret cast
273 if (sent != static_cast<int>(header.size())) {
274 return false;
275 }
276
277 state->httpHeaderSent = true;
278 return true;
279}
280
281HttpStreamServer::ClientState* HttpStreamServer::getOrCreateClientState(u32 clientId) {
282 // Check if state already exists

Callers

nothing calls this directly

Calls 4

appendMethod · 0.45
sendMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected