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

Method handle_receiving

src/fl/net/http/fetch_request.cpp.hpp:235–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void FetchRequest::handle_receiving() {
236 char buffer[4096];
237 ssize_t bytes = recv(mSocketFd, buffer, sizeof(buffer), 0);
238
239 if (bytes > 0) {
240 mResponseBuffer.append(buffer, static_cast<size_t>(bytes));
241 mStateStartTime = fl::millis(); // Reset timeout on data received
242 } else if (bytes == 0) {
243 // Connection closed - parse response and complete
244 Response resp = parse_http_response(mResponseBuffer);
245 complete_success(resp);
246 } else {
247 int err = GET_SOCKET_ERROR();
248 if (err == SOCKET_ERROR_WOULD_BLOCK) {
249 // Check timeout (5 seconds)
250 if (fl::millis() - mStateStartTime > 5000) {
251 complete_error("Response timeout");
252 }
253 // else: Not ready, try again on next update()
254 } else {
255 complete_error("Receive failed");
256 }
257 }
258}
259
260Response FetchRequest::parse_http_response(const fl::string& raw) {
261 const char* data = raw.c_str();

Callers

nothing calls this directly

Calls 3

recvFunction · 0.50
millisFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected