aboutsummaryrefslogtreecommitdiff
path: root/src/http.c
diff options
context:
space:
mode:
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) {