mirror of
https://github.com/opus-tango/http-server-in-c.git
synced 2026-03-20 03:55:25 +00:00
add some debug logs
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* handle_request.
|
||||
*/
|
||||
void* client_handler(void* args) {
|
||||
log_message(LOG_DEBUG, "Client handler started");
|
||||
// Cast args
|
||||
int client = *((int*)args);
|
||||
char* buffer = (char*)malloc(BUFFER_SIZE);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "request_handler.h"
|
||||
|
||||
void handle_request(char* request, int length, http_response* response) {
|
||||
log_message(LOG_DEBUG, "Handling request");
|
||||
// Parse request into struct
|
||||
http_request* req = create_http_request();
|
||||
parse_http_request(request, length, req);
|
||||
@@ -28,6 +29,7 @@ void handle_request(char* request, int length, http_response* response) {
|
||||
}
|
||||
|
||||
void parse_http_request(char* request, int length, struct http_request* req) {
|
||||
log_message(LOG_DEBUG, "Parsing request");
|
||||
// Get the end of the first line
|
||||
char* request_line_end = strstr(request, "\r\n");
|
||||
if (request_line_end == NULL) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "response_builder.h"
|
||||
|
||||
void response_handle_get(http_request* req, http_response* res) {
|
||||
log_message(LOG_DEBUG, "Handling GET request");
|
||||
log_message(LOG_INFO, "GET request %s", req->url);
|
||||
// Extract the path from the request URL
|
||||
char* basepath = "./public";
|
||||
@@ -50,6 +51,7 @@ void response_handle_put(http_request* req, http_response* res) {
|
||||
|
||||
void response_build_static_file(char* file_path, content_type content_type,
|
||||
status_code status_code, http_response* res) {
|
||||
log_message(LOG_DEBUG, "Building static file response");
|
||||
// Open the file and verify that the file exists
|
||||
FILE* file = fopen(file_path, "rb");
|
||||
if (file == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user