| 251 | } |
| 252 | |
| 253 | bool 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 | |
| 281 | HttpStreamServer::ClientState* HttpStreamServer::getOrCreateClientState(u32 clientId) { |
| 282 | // Check if state already exists |