Finish code part

This commit is contained in:
2026-06-01 17:18:38 -07:00
parent 3ab01575a2
commit 698f67d174
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
CC=clang CC=clang
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c23 -D_POSIX_C_SOURCE=200809L -pthread -O2 CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c23 -D_POSIX_C_SOURCE=200809L -pthread -O2
CFLAGS+=-Og -g -fsanitize=address,undefined #CFLAGS+=-Og -g -fsanitize=address,undefined
SRCS=main.c threadpool.c util.c server.c http.c SRCS=main.c threadpool.c util.c server.c http.c
OBJS=$(SRCS:%.c=bin/%.o) OBJS=$(SRCS:%.c=bin/%.o)
+9 -9
View File
@@ -4,7 +4,7 @@
* - main.c: Argument parsing and high-level control * - main.c: Argument parsing and high-level control
* - http.c: HTTP request parsing and response formatting * - http.c: HTTP request parsing and response formatting
* - server.c: Abstraction over sockets * - server.c: Abstraction over sockets
* - threadpool.c: Thread pool and wokr queue implementation * - threadpool.c: Thread pool and woker queue implementation
* - util.c: Misc. utility functions * - util.c: Misc. utility functions
*/ */
#include "http.h" #include "http.h"
@@ -279,20 +279,20 @@ static void handle_put_request(FILE *conn, HTTPRequest *restrict req) {
(size_t) content_length < sizeof(read_buff) ? (size_t) content_length (size_t) content_length < sizeof(read_buff) ? (size_t) content_length
: sizeof(read_buff), : sizeof(read_buff),
conn); conn);
if (ferror(conn) || write(temp_fd, read_buff, read_size) < 0) { content_length -= read_size;
write_audit_log_entry(req, 500); if (feof(conn) && content_length) {
send_simple_response(conn, 500);
close(temp_fd);
unlink(temp_file);
return;
} else if (feof(conn)) {
write_audit_log_entry(req, 400); write_audit_log_entry(req, 400);
send_simple_response(conn, 400); send_simple_response(conn, 400);
close(temp_fd); close(temp_fd);
unlink(temp_file); unlink(temp_file);
return; return;
} else if (ferror(conn) || write(temp_fd, read_buff, read_size) < 0) {
write_audit_log_entry(req, 500);
send_simple_response(conn, 500);
close(temp_fd);
unlink(temp_file);
return;
} }
content_length -= read_size;
} }
close(temp_fd); close(temp_fd);
int status; int status;