diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index 632e403..afdcf89 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -2146,25 +2146,28 @@ public define String We send 2 headers 'Content-Type' and 'Content-Length'. define List(HTTP_header) - headers_for_send_file - ( - MIME mime_type, - Int size, - String etag, - Maybe(FileTimes) mb_ftimes, - ) = - with headers = (List(HTTP_header)) + headers_for_send_file + ( + MIME mime_type, + String filename, + Int size, + String etag, + Maybe(FileTimes) mb_ftimes, + )= + with headers = (List(HTTP_header)) [ http_header("Content-Type", to_String(mime_type)), http_header("Etag", "\""+etag+"\""), http_header("Content-Length",to_decimal(size)), + http_header("Content-Disposition", "attachment; filename=\"" + filename +"\"") + ], if mb_ftimes is { failure then headers, success(ftimes) then [http_header("Last-Modified", format_http_date(to_Int(ftimes.last_modified))) . headers] } - . +. @@ -2249,7 +2252,7 @@ define One { false then forget(reliable_write(connection,to_byte_array("HTTP/1.1 200 OK"+crlf))); - forget(reliable_write(connection,[format_headers(headers + headers_for_send_file(mime_type, size, current_etag, mb_ftimes)) , crlf])); + forget(reliable_write(connection,[format_headers(headers + headers_for_send_file(mime_type, filename, size, current_etag, mb_ftimes)) , crlf])); //forget(copy_file_to_Connection(file, connection, size)), send_file_body(desc,connection,file,size,0,filename), true then @@ -2380,19 +2383,21 @@ define One log_journal_msg(desc,"Cannot find file '"+absolute_path+"'.\n"), success(f) then with size = file_size(f), - mime_type = mime("application", "octet-stream", []), - + since split_filename_extension(absolute_path) is (filename, extension), + with mime_type = get_MIME_from_extension("."+extension), + println("send file answer: "+filename+" ext: "+extension+ " uri :" +uri); send_file( desc, connection, input_headers, output_headers, size, - file(f), - uri, - absolute_path, - mime_type, - action_before_send_file) + file(f), + filename+"."+extension, + absolute_path, + mime_type, + action_before_send_file + ) } . -- libgit2 0.21.4