diff --git a/src/file.c b/src/file.c index f7fd66a..1c9867c 100644 --- a/src/file.c +++ b/src/file.c @@ -9,16 +9,13 @@ void get_file_path(char *uri, char *file_path) { *question = '\0'; } - char index_file[] = "index.html"; + char index_file[] = "index.html"; // 11 chars + \0 if(uri[strlen(uri) - 1] == '/') { - strncat(uri, index_file, 20); + strncat(uri, index_file, strlen(index_file) + 1); } - printf("%s\n", uri); - strncpy(file_path, file_dir, 20); - printf("%s\n", file_path); - strncat(file_path, uri, 30); - printf("%s\n", file_path); + strncpy(file_path, file_dir, strlen(file_dir) + 1); + strncat(file_path, uri, strlen(uri) + 1); const char *dot = strrchr(file_path, '.'); if(!dot || dot == file_path) { diff --git a/src/server.c b/src/server.c index 5e1972c..6d2b242 100644 --- a/src/server.c +++ b/src/server.c @@ -113,11 +113,8 @@ int main() { } else { char file_path[4096]; get_file_path(uri, file_path); - printf("Getting file\n"); - FILE *file = fopen(file_path, "r"); if(!file) { - printf("File does not exist\n"); char not_found[] = "404 page not found"; send_response(client_sock_fd, NOT_FOUND_HEAD, "text/plain", not_found, (int)sizeof(not_found)); } else { @@ -125,8 +122,6 @@ int main() { unsigned long file_size = ftell(file); fseek(file, 0, SEEK_SET); - printf("Size of File: %ld\n", file_size); - char mime_type[15]; get_mime_type(uri, mime_type);