mimetype check beta
This commit is contained in:
parent
218e41082c
commit
c944c6ed63
24
src/file.c
24
src/file.c
|
@ -24,5 +24,29 @@ void get_file_path(char *uri, char *file_path) {
|
|||
}
|
||||
|
||||
void get_mime_type(char *file, char *mime) {
|
||||
const char *dot = strrchr(file, '.');
|
||||
|
||||
if (dot == NULL)
|
||||
strcpy(mime, "text/html");
|
||||
|
||||
else if (strcmp(dot, ".html") == 0)
|
||||
strcpy(mime, "text/html");
|
||||
|
||||
else if (strcmp(dot, ".css") == 0)
|
||||
strcpy(mime, "text/css");
|
||||
|
||||
else if (strcmp(dot, ".js") == 0)
|
||||
strcpy(mime, "application/js");
|
||||
|
||||
else if (strcmp(dot, ".jpg") == 0)
|
||||
strcpy(mime, "image/jpeg");
|
||||
|
||||
else if (strcmp(dot, ".png") == 0)
|
||||
strcpy(mime, "image/png");
|
||||
|
||||
else if (strcmp(dot, ".gif") == 0)
|
||||
strcpy(mime, "image/gif");
|
||||
|
||||
else
|
||||
strcpy(mime, "text/html");
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define MAX_PATH_SIZE 4096
|
||||
|
||||
void get_file_path(char *uri, char *file_path);
|
||||
void get_mime_type(char *file, char *mime);
|
||||
|
|
Loading…
Reference in New Issue