From 7d4dc46b80b4692f00bdcdb9d08f85199a25657d Mon Sep 17 00:00:00 2001 From: SimonFJ20 Date: Thu, 13 Mar 2025 13:56:28 +0100 Subject: [PATCH] move http into http/ --- backend/compile_flags.txt | 1 + backend/src/controllers.h | 2 +- backend/src/controllers/general.c | 2 +- backend/src/controllers/products.c | 2 +- backend/src/controllers/sessions.c | 2 +- backend/src/controllers/users.c | 2 +- backend/src/{http_server.h => http.h} | 0 backend/src/{ => http}/http_response_code_string.c | 0 backend/src/{ => http}/http_server.c | 10 ++++++---- backend/src/{ => http}/http_server_internal.h | 4 ++-- backend/src/main.c | 2 +- 11 files changed, 15 insertions(+), 12 deletions(-) rename backend/src/{http_server.h => http.h} (100%) rename backend/src/{ => http}/http_response_code_string.c (100%) rename backend/src/{ => http}/http_server.c (98%) rename backend/src/{ => http}/http_server_internal.h (97%) diff --git a/backend/compile_flags.txt b/backend/compile_flags.txt index 32f238a..f79c88b 100644 --- a/backend/compile_flags.txt +++ b/backend/compile_flags.txt @@ -7,4 +7,5 @@ -pedantic -pedantic-errors -Wno-unused-parameter +-Wno-unused-function diff --git a/backend/src/controllers.h b/backend/src/controllers.h index d3ce094..6f38c5c 100644 --- a/backend/src/controllers.h +++ b/backend/src/controllers.h @@ -1,7 +1,7 @@ #pragma once #include "db.h" -#include "http_server.h" +#include "http.h" #include #include diff --git a/backend/src/controllers/general.c b/backend/src/controllers/general.c index c876953..db31270 100644 --- a/backend/src/controllers/general.c +++ b/backend/src/controllers/general.c @@ -1,5 +1,5 @@ #include "../controllers.h" -#include "../http_server.h" +#include "../http.h" #include "../models_json.h" void route_get_index(HttpCtx* ctx) diff --git a/backend/src/controllers/products.c b/backend/src/controllers/products.c index 0a2e88e..7f0a58b 100644 --- a/backend/src/controllers/products.c +++ b/backend/src/controllers/products.c @@ -1,5 +1,5 @@ #include "../controllers.h" -#include "../http_server.h" +#include "../http.h" #include "../models_json.h" #include "../str_util.h" diff --git a/backend/src/controllers/sessions.c b/backend/src/controllers/sessions.c index 06d927b..9f9dd15 100644 --- a/backend/src/controllers/sessions.c +++ b/backend/src/controllers/sessions.c @@ -1,5 +1,5 @@ #include "../controllers.h" -#include "../http_server.h" +#include "../http.h" #include "../models_json.h" #include "../str_util.h" #include diff --git a/backend/src/controllers/users.c b/backend/src/controllers/users.c index b57cf70..4968588 100644 --- a/backend/src/controllers/users.c +++ b/backend/src/controllers/users.c @@ -1,5 +1,5 @@ #include "../controllers.h" -#include "../http_server.h" +#include "../http.h" #include "../models_json.h" #include "../str_util.h" #include diff --git a/backend/src/http_server.h b/backend/src/http.h similarity index 100% rename from backend/src/http_server.h rename to backend/src/http.h diff --git a/backend/src/http_response_code_string.c b/backend/src/http/http_response_code_string.c similarity index 100% rename from backend/src/http_response_code_string.c rename to backend/src/http/http_response_code_string.c diff --git a/backend/src/http_server.c b/backend/src/http/http_server.c similarity index 98% rename from backend/src/http_server.c rename to backend/src/http/http_server.c index 1c7f38e..a2f02a8 100644 --- a/backend/src/http_server.c +++ b/backend/src/http/http_server.c @@ -1,6 +1,6 @@ -#include "http_server.h" +#include "../http.h" +#include "../str_util.h" #include "http_server_internal.h" -#include "str_util.h" #include #include #include @@ -269,7 +269,8 @@ static inline void worker_handle_request(Worker* worker, Client* client) (void)worker; uint8_t* buffer = calloc(MAX_HEADER_BUFFER_SIZE, sizeof(char)); - ssize_t bytes_received = recv(client->file, buffer, MAX_HEADER_BUFFER_SIZE * sizeof(char), 0); + ssize_t bytes_received + = recv(client->file, buffer, MAX_HEADER_BUFFER_SIZE * sizeof(char), 0); if (bytes_received == -1) { fprintf(stderr, "error: could not receive request\n"); @@ -312,7 +313,8 @@ static inline void worker_handle_request(Worker* worker, Client* client) // HACK // TODO: We should treat the input as a stream rather than a block. - // Look at either @camper0008's stream example or other HTTP-server implementations. + // Look at either @camper0008's stream example or other HTTP-server + // implementations. size_t defacto_length = strlen(body); int attempts = 0; const int arbitrary_max_attempts = 10; diff --git a/backend/src/http_server_internal.h b/backend/src/http/http_server_internal.h similarity index 97% rename from backend/src/http_server_internal.h rename to backend/src/http/http_server_internal.h index d9562d5..a31a9a9 100644 --- a/backend/src/http_server_internal.h +++ b/backend/src/http/http_server_internal.h @@ -1,7 +1,7 @@ #pragma once -#include "collection.h" -#include "http_server.h" +#include "../collection.h" +#include "../http.h" #include #include #include diff --git a/backend/src/main.c b/backend/src/main.c index 2990f2d..20e2e2c 100644 --- a/backend/src/main.c +++ b/backend/src/main.c @@ -1,6 +1,6 @@ #include "controllers.h" #include "db_sqlite.h" -#include "http_server.h" +#include "http.h" #include "json.h" #include "models.h" #include "models_json.h"