Fixed resetConnection()
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,8 +1,8 @@
|
|||||||
SRC = $(wildcard src/*.c)
|
SRC = $(wildcard src/*.c)
|
||||||
OBJ = $(subst .c,.o,$(subst src,work,$(SRC)))
|
OBJ = $(subst .c,.o,$(subst src,work,$(SRC)))
|
||||||
LIBS =
|
LIBS =
|
||||||
CFLAGS := -pipe -Wall -Wpedantic -Werror
|
CFLAGS := -O2 -pipe -Wall -Wpedantic -Werror
|
||||||
CFLAGS += -Isrc/include -pthread -ggdb
|
CFLAGS += -Isrc/include -pthread
|
||||||
INSTALLDIR := /usr/bin
|
INSTALLDIR := /usr/bin
|
||||||
OUT = swebs
|
OUT = swebs
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ Connection *newConnection(int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetConnection(Connection *conn) {
|
void resetConnection(Connection *conn) {
|
||||||
conn->type = RECEIVE_REQUEST;
|
conn->progress = RECEIVE_REQUEST;
|
||||||
conn->fieldCount = 0;
|
conn->fieldCount = 0;
|
||||||
free(conn->body);
|
free(conn->body);
|
||||||
free(conn->path);
|
free(conn->path);
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ static void readResponse(Connection *conn, char *path) {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
sendConnection(conn,
|
sendConnection(conn,
|
||||||
"HTTP/1.1 200 OK\r\n"
|
"HTTP/1.1 200 OK\r\n"
|
||||||
"Content-Type: text/html; charset=UTF-8\r\n"
|
|
||||||
"Server: swebs/0.1\r\n"
|
"Server: swebs/0.1\r\n"
|
||||||
"Content-Length: %ld\r\n"
|
"Content-Length: %ld\r\n"
|
||||||
"\r\n", len
|
"\r\n", len
|
||||||
);
|
);
|
||||||
write(conn->fd, data, len);
|
write(conn->fd, data, len);
|
||||||
free(data);
|
free(data);
|
||||||
|
fsync(conn->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sendResponse(Connection *conn, Sitefile *site) {
|
int sendResponse(Connection *conn, Sitefile *site) {
|
||||||
|
|||||||
Reference in New Issue
Block a user