| 568 | } |
| 569 | |
| 570 | bool Server::send_response(int client_fd, const Response& response) { |
| 571 | string data = response.to_string(); |
| 572 | const char* ptr = data.c_str(); |
| 573 | size_t remaining = data.size(); |
| 574 | |
| 575 | while (remaining > 0) { |
| 576 | #ifdef FL_IS_WIN |
| 577 | int sent = send(client_fd, ptr, static_cast<int>(remaining), 0); |
| 578 | #else |
| 579 | ssize_t sent = send(client_fd, ptr, remaining, 0); |
| 580 | #endif |
| 581 | |
| 582 | if (sent <= 0) { |
| 583 | return false; |
| 584 | } |
| 585 | |
| 586 | ptr += sent; |
| 587 | remaining -= static_cast<size_t>(sent); |
| 588 | } |
| 589 | |
| 590 | return true; |
| 591 | } |
| 592 | |
| 593 | optional<RouteHandler> Server::find_handler(const string& method, const string& path) const { |
| 594 | for (const auto& entry : mRoutes) { |