| 268 | } |
| 269 | |
| 270 | void LlmProxyService::HandleClient(uintptr_t client_sock) { |
| 271 | SOCKET sock = static_cast<SOCKET>(client_sock); |
| 272 | bool keep_alive = true; |
| 273 | |
| 274 | while (keep_alive && running_) { |
| 275 | std::string method, path, body; |
| 276 | if (!ParseHttpRequest(client_sock, method, path, body, keep_alive)) |
| 277 | break; |
| 278 | |
| 279 | // Route |
| 280 | if (method == "POST" && (path == "/v1/chat/completions" || |
| 281 | path == "/chat/completions")) { |
| 282 | HandleChatCompletions(client_sock, body, keep_alive); |
| 283 | } else if (method == "GET" && (path == "/v1/models" || path == "/models")) { |
| 284 | HandleModels(client_sock, keep_alive); |
| 285 | } else { |
| 286 | SendErrorResponse(client_sock, 404, "Not Found", |
| 287 | "Unknown endpoint: " + path, keep_alive); |
| 288 | } |
| 289 | } |
| 290 | closesocket(sock); |
| 291 | } |
| 292 | |
| 293 | bool LlmProxyService::ParseHttpRequest(uintptr_t sock_u, std::string& method, |
| 294 | std::string& path, std::string& body, |
nothing calls this directly
no outgoing calls
no test coverage detected