From fbb3a4e8cd28b04cb8d36d6e10d42a7019898cc2 Mon Sep 17 00:00:00 2001 From: Nate Choe Date: Sat, 22 Jan 2022 20:22:22 -0600 Subject: [PATCH] Fixed resetConnection() --- Makefile | 4 ++-- src/connections.c | 2 +- src/responses.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 98d3972..942c338 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ SRC = $(wildcard src/*.c) OBJ = $(subst .c,.o,$(subst src,work,$(SRC))) LIBS = -CFLAGS := -pipe -Wall -Wpedantic -Werror -CFLAGS += -Isrc/include -pthread -ggdb +CFLAGS := -O2 -pipe -Wall -Wpedantic -Werror +CFLAGS += -Isrc/include -pthread INSTALLDIR := /usr/bin OUT = swebs diff --git a/src/connections.c b/src/connections.c index 12ebdd0..efc3b1c 100644 --- a/src/connections.c +++ b/src/connections.c @@ -65,7 +65,7 @@ Connection *newConnection(int fd) { } void resetConnection(Connection *conn) { - conn->type = RECEIVE_REQUEST; + conn->progress = RECEIVE_REQUEST; conn->fieldCount = 0; free(conn->body); free(conn->path); diff --git a/src/responses.c b/src/responses.c index cfde26e..51c38e0 100644 --- a/src/responses.c +++ b/src/responses.c @@ -63,13 +63,13 @@ static void readResponse(Connection *conn, char *path) { fclose(file); sendConnection(conn, "HTTP/1.1 200 OK\r\n" - "Content-Type: text/html; charset=UTF-8\r\n" "Server: swebs/0.1\r\n" "Content-Length: %ld\r\n" "\r\n", len ); write(conn->fd, data, len); free(data); + fsync(conn->fd); } int sendResponse(Connection *conn, Sitefile *site) {