| 95 | |
| 96 | // C++ callback function that JavaScript can call when fetch completes |
| 97 | extern "C" EMSCRIPTEN_KEEPALIVE void js_fetch_success_callback(u32 request_id, const char* content) { |
| 98 | FL_WARN("Fetch success callback received for request " << request_id << ", content length: " << strlen(content)); |
| 99 | |
| 100 | auto callback_opt = getCallbackManager().takeCallback(request_id); |
| 101 | if (callback_opt) { |
| 102 | // Create a successful response object using unified fl::response |
| 103 | fl::net::http::Response response(200, "OK"); |
| 104 | response.set_body(fl::string(content)); |
| 105 | response.set_header("content-type", "text/html"); // Default content type |
| 106 | |
| 107 | (*callback_opt)(response); |
| 108 | } else { |
| 109 | FL_WARN("Warning: No pending callback found for fetch success request " << request_id); |
| 110 | } |
| 111 | // Wake any pthread parked inside fl::platforms::await(). |
| 112 | fl::platforms::ICoroutineRuntime::instance().wakeWaiters(); |
| 113 | } |
| 114 | |
| 115 | // C++ error callback function that JavaScript can call when fetch fails |
| 116 | extern "C" EMSCRIPTEN_KEEPALIVE void js_fetch_error_callback(u32 request_id, const char* error_message) { |
nothing calls this directly
no test coverage detected