working on adding different types of requests

This commit is contained in:
2025-10-06 13:41:12 -07:00
parent dba3bf3030
commit 5f058a01bf
3 changed files with 29 additions and 0 deletions

View File

@@ -25,12 +25,29 @@ void handleClient(int sock) {
continue;
}
HttpRequestHeader rh;
char packetBuilder[HTTP_RECIVE_PACKET_SIZE] = "";
int sizeOfPacket = recv(sock, packetBuilder, HTTP_RECIVE_PACKET_SIZE, 0);
char* packetBuffer = malloc(sizeOfPacket);
while ((sizeOfPacket = recv(sock, packetBuilder, HTTP_RECIVE_PACKET_SIZE, 0)) > 0) {
strncat(packetBuffer, packetBuilder, sizeOfPacket);
}
HttpRequestHeaderFromS(&rh, packetBuffer);
free(packetBuffer);
FILE* file = fopen("./web/index.html", "r");
if (file == NULL) {
perror("that file dose not exists");
return;
}
char* fileBuffer;
fseek(file, 0, SEEK_END);