From e34205bd390cfc75a8a99120dce68ec21c32ec1a Mon Sep 17 00:00:00 2001 From: Quinten Date: Wed, 29 Oct 2025 15:51:32 +0100 Subject: [PATCH] formatting --- webserv/client/Client.cpp | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/webserv/client/Client.cpp b/webserv/client/Client.cpp index 2abffa5..5a9f899 100644 --- a/webserv/client/Client.cpp +++ b/webserv/client/Client.cpp @@ -86,41 +86,40 @@ void Client::request() { Log::info("Received request: " + httpRequest_->getHttpVersion() + " " + httpRequest_->getMethod() + " " + httpRequest_->getTarget() + " "); - - Log::debug("Request details", - { - {"request_method", httpRequest_->getMethod()}, - {"request_target", httpRequest_->getTarget()}, - {"http_version", httpRequest_->getHttpVersion()}, - {"headers", httpRequest_->getHeaders().toString()}, - {"body", httpRequest_->getBody()}, - {"state", std::to_string(static_cast(httpRequest_->getState()))}, - }); - try - { - // Thoughts: if a handler isn't returned, this could because of the error handler already setting - // up the response so, maybe we don't need to throw a 500 when no handler. Because that would - // override the actual error response. How about the router, or a handler, throws an exception if - // something goes wrong, and we catch it here to make a 500 response? - handler_ = router_->handleRequest(); - if (handler_ != nullptr) - { - handler_->handle(); - } - } - catch (const RequestValidator::ValidationException &e) - { - Log::error("Validation Exception during request handling: " + std::string(e.what())); - ErrorHandler::createErrorResponse(e.code(), *httpResponse_); - return; - } - catch (const std::exception &e) - { - Log::error("Exception during request handling: " + std::string(e.what())); - ErrorHandler::createErrorResponse(500, *httpResponse_); - return; - } + Log::debug("Request details", { + {"request_method", httpRequest_->getMethod()}, + {"request_target", httpRequest_->getTarget()}, + {"http_version", httpRequest_->getHttpVersion()}, + {"headers", httpRequest_->getHeaders().toString()}, + // {"body", httpRequest_->getBody()}, + {"state", std::to_string(static_cast(httpRequest_->getState()))}, + }); + + try + { + // Thoughts: if a handler isn't returned, this could because of the error handler already setting + // up the response so, maybe we don't need to throw a 500 when no handler. Because that would + // override the actual error response. How about the router, or a handler, throws an exception if + // something goes wrong, and we catch it here to make a 500 response? + handler_ = router_->handleRequest(); + if (handler_ != nullptr) + { + handler_->handle(); + } + } + catch (const RequestValidator::ValidationException &e) + { + Log::error("Validation Exception during request handling: " + std::string(e.what())); + ErrorHandler::createErrorResponse(e.code(), *httpResponse_); + return; + } + catch (const std::exception &e) + { + Log::error("Exception during request handling: " + std::string(e.what())); + ErrorHandler::createErrorResponse(500, *httpResponse_); + return; + } } else { @@ -200,4 +199,5 @@ std::string Client::getClientAddress() const noexcept return ""; } + // NOLINTEND \ No newline at end of file