| 431 | } |
| 432 | |
| 433 | void LlmProxyService::HandleClient(int client_fd) { |
| 434 | pthread_setname_np(pthread_self(), "llm-handler"); |
| 435 | bool keep_alive = true; |
| 436 | while (keep_alive && running_.load()) { |
| 437 | std::string method; |
| 438 | std::string path; |
| 439 | std::string body; |
| 440 | if (!ParseHttpRequest(client_fd, method, path, body, keep_alive)) break; |
| 441 | |
| 442 | if (method == "POST" && (path == "/v1/chat/completions" || |
| 443 | path == "/chat/completions")) { |
| 444 | HandleChatCompletions(client_fd, body, keep_alive); |
| 445 | } else if (method == "GET" && (path == "/v1/models" || path == "/models")) { |
| 446 | HandleModels(client_fd, keep_alive); |
| 447 | } else { |
| 448 | SendErrorResponse(client_fd, 404, "Not Found", |
| 449 | "Unknown endpoint: " + path, keep_alive); |
| 450 | } |
| 451 | } |
| 452 | ::close(client_fd); |
| 453 | } |
| 454 | |
| 455 | bool LlmProxyService::ParseHttpRequest(int client_fd, std::string& method, |
| 456 | std::string& path, std::string& body, |
nothing calls this directly
no outgoing calls
no test coverage detected