Actually used the SEND_RESPONSE phase

This commit is contained in:
Nate Choe
2022-01-30 17:57:20 -06:00
parent f3694d3b43
commit 1888bb9518
6 changed files with 51 additions and 28 deletions

View File

@@ -198,7 +198,20 @@ static int processChar(Connection *conn, char c, Sitefile *site) {
}
if (conn->progress == RECEIVE_BODY &&
conn->receivedBody >= conn->bodylen)
sendResponse(conn, site);
getResponse(conn, site);
if (conn->progress == SEND_RESPONSE) {
for (;;) {
char buffer[1024];
size_t readLen = read(conn->fd, buffer, sizeof(buffer));
if (readLen == 0)
break;
size_t writeLen = sendStream(conn->stream,
buffer, readLen);
if (writeLen < readLen)
return 1;
}
resetConnection(conn);
}
return 0;
}