@@ -71,6 +71,8 @@ void Teapot::requestHandler(SOCKET client_socket)
71
71
auto request = parseRequest (client_socket);
72
72
std::string body;
73
73
std::string content_type;
74
+ std::string method;
75
+ std::string uri;
74
76
unsigned int status_code = 500 ; // Default to internal server error in case of early failure
75
77
76
78
try
@@ -79,14 +81,12 @@ void Teapot::requestHandler(SOCKET client_socket)
79
81
{
80
82
context->request = &(*request);
81
83
this ->sanitizer_middleware .handle (context.get ());
82
- std::string uri = request->getUri ();
84
+ uri = request->getUri ();
83
85
if (uri == " /" )
84
86
uri = " /index.html" ; // Normalize root access to a specific file, e.g., index.html
85
- std::string method = request->getMethod ();
87
+ method = request->getMethod ();
86
88
content_type = determineContentType (uri); // Determine content type early based on URI
87
89
88
- std::cout << " [" << request->getDate () << " ] " << this ->socket .getClientIp () + " " << method << " " << uri << " HTTP/1.1 " ;
89
-
90
90
if (method == " GET" )
91
91
{
92
92
// Check for predefined routes or responses before attempting to read a file
@@ -151,7 +151,7 @@ void Teapot::requestHandler(SOCKET client_socket)
151
151
this ->cors_middleware .handle (context.get ());
152
152
this ->security_middleware .handle (context.get ());
153
153
154
- std::cout << response. getStatusCode () + " " + response.getStatusCodeDescription () << " \n " ;
154
+ LOG_INFO (logger, this -> socket . getClientIp () + " " + method + " " + uri + " HTTP/1.1 " + response.getStatusCode () + " " + response. getStatusCodeDescription ()) ;
155
155
156
156
std::string raw_response = response.getRawResponse ();
157
157
this ->socket .sendData (client_socket, raw_response.c_str (), raw_response.length (), 0 );
0 commit comments