forgot to get mime type when downloading files
This commit is contained in:
parent
5e2d6afe3b
commit
701a9be612
18
src/www.c
18
src/www.c
@ -895,11 +895,29 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
|||||||
if (conf.file_directories[file_dir]->display_on_web) {
|
if (conf.file_directories[file_dir]->display_on_web) {
|
||||||
// send file
|
// send file
|
||||||
filename = www_files_get_from_area(file_dir, file_sub, filen);
|
filename = www_files_get_from_area(file_dir, file_sub, filen);
|
||||||
|
mime = NULL;
|
||||||
|
// get mimetype
|
||||||
|
for (i=strlen(filename);i>0;--i) {
|
||||||
|
if (filename[i] == '.') {
|
||||||
|
mime = www_get_mime_type(&filename[i+1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (filename[i] == '/') {
|
||||||
|
mime = www_get_mime_type(NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mime = NULL) {
|
||||||
|
mime = www_get_mime_type(NULL);
|
||||||
|
}
|
||||||
free(filen);
|
free(filen);
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
if (stat(filename, &s) == 0 && S_ISREG(s.st_mode)) {
|
if (stat(filename, &s) == 0 && S_ISREG(s.st_mode)) {
|
||||||
fno = open(filename, O_RDONLY);
|
fno = open(filename, O_RDONLY);
|
||||||
if (fno != -1) {
|
if (fno != -1) {
|
||||||
|
|
||||||
|
|
||||||
response = MHD_create_response_from_fd(s.st_size, fno);
|
response = MHD_create_response_from_fd(s.st_size, fno);
|
||||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, mime);
|
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, mime);
|
||||||
sprintf(buffer, "%ld", s.st_size);
|
sprintf(buffer, "%ld", s.st_size);
|
||||||
|
Reference in New Issue
Block a user