This commit is contained in:
Win 2024-06-03 16:36:45 +07:00
parent c944c6ed63
commit bcc7058591
1 changed files with 9 additions and 4 deletions

View File

@ -116,10 +116,15 @@ int main() {
send_response(client_sock_fd, NOT_FOUND_HEAD, "text/html", NULL, 0); send_response(client_sock_fd, NOT_FOUND_HEAD, "text/html", NULL, 0);
} }
fseek(file, 0, SEEK_END);
unsigned long file_size = ftell(file);
// int body_size = snprintf(body, 100, "%s\r\n", "hello what up bruh"); fseek(file, 0, SEEK_SET);
send_response(client_sock_fd, OK_HEAD, "text/html", body, (body_size + 1));
printf("Size of File: %ld\n", file_size);
send_response(client_sock_fd, OK_HEAD, "text/html", file, file_size);
fclose(file);
} }
close(client_sock_fd); close(client_sock_fd);