aboutsummaryrefslogtreecommitdiff
path: root/src/http.c
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-08-08 00:37:44 -0400
committerfrosty <gabriel@bwaaa.monster>2026-08-08 00:37:44 -0400
commitb6951c18912c82e7863ebd6c6c77b891ad9aea0c (patch)
tree7e7e067b93b4df878f000ec4a272334a81aba85f /src/http.c
parent42fe6caf63acdd25e5674d91c13a9ab15f948b7f (diff)
downloadbeaker-b6951c18912c82e7863ebd6c6c77b891ad9aea0c.tar.gz
fix: centralise empty HTTP status responses
Diffstat (limited to 'src/http.c')
-rw-r--r--src/http.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/http.c b/src/http.c
index 891fca3..778bf51 100644
--- a/src/http.c
+++ b/src/http.c
@@ -48,6 +48,26 @@ static void build_cookie_headers(char *cookie_headers_buffer,
}
}
+void send_status(const char *status_line) {
+ if (current_client_socket == -1) {
+ fprintf(stderr, "[ERROR] send_status: No client socket set. Cannot send response.\n");
+ return;
+ }
+
+ char http_response[BUFFER_SIZE];
+ snprintf(http_response, sizeof(http_response),
+ "HTTP/1.1 %s\r\n"
+ "Content-Length: 0\r\n"
+ "Connection: close\r\n"
+ "\r\n",
+ status_line);
+
+ if (send(current_client_socket, http_response, strlen(http_response), 0) < 0) {
+ perror("Error sending HTTP status");
+ fprintf(stderr, "[ERROR] send_status: Failed to send HTTP status.\n");
+ }
+}
+
void send_response(const char *html) {
if (current_client_socket == -1) {