/[mldonkey]/mldonkey/src/daemon/driver/driverControlers.ml
ViewVC logotype

Diff of /mldonkey/src/daemon/driver/driverControlers.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by spiralvoice, Mon Nov 21 00:12:44 2005 UTC revision 1.51 by spiralvoice, Mon Nov 21 00:48:38 2005 UTC
# Line 719  type file_ext = Line 719  type file_ext =
719  | JPEG  | JPEG
720  | JAVASCRIPT  | JAVASCRIPT
721  | MPEG  | MPEG
722    | AVI
723    | WMV
724    | ASF
725    | MOV
726    | OGM
727    | RM
728    | MKV
729  | PNG  | PNG
730    | GIF
731    | MP3
732    | WMA
733    | OGG
734  | TEXTS  | TEXTS
735  | UNKN  | UNKN
736  | WML  | WML
# Line 733  let extension_to_file_ext extension = Line 744  let extension_to_file_ext extension =
744    | "htm"    | "htm"
745    | "html" -> HTMLS    | "html" -> HTMLS
746    | "ico" -> ICON    | "ico" -> ICON
747      | "jpe"
748    | "jpeg"    | "jpeg"
749    | "jpg" -> JPEG    | "jpg" -> JPEG
750    | "js" -> JAVASCRIPT    | "js" -> JAVASCRIPT
751      | "mpe"
752    | "mpeg"    | "mpeg"
753    | "mpg" -> MPEG    | "mpg" -> MPEG
754      | "avi" -> AVI
755      | "wmv" -> WMV
756      | "asf" -> ASF
757      | "mov"
758      | "movie"
759      | "qt" -> MOV
760      | "ogm" -> OGM
761      | "ra"
762      | "ram"
763      | "rm"
764      | "rmvb"
765      | "rv9"
766      | "rt" -> RM
767      | "mkv" -> MKV
768    | "png" -> PNG    | "png" -> PNG
769      | "gif" -> GIF
770      | "mp3" -> MP3
771      | "wma" -> WMA
772      | "ogg" -> OGG
773    | "txt" -> TEXTS    | "txt" -> TEXTS
774    | "wml" -> WML    | "wml" -> WML
775    | _ -> UNKN    | _ -> UNKN
# Line 753  let ext_to_file_type ext = Line 784  let ext_to_file_type ext =
784    | JAVASCRIPT -> TXT    | JAVASCRIPT -> TXT
785    | JPEG -> BIN    | JPEG -> BIN
786    | MPEG -> BIN    | MPEG -> BIN
787      | AVI -> BIN
788      | WMV -> BIN
789      | ASF -> BIN
790      | MOV -> BIN
791      | OGM -> BIN
792      | RM -> BIN
793      | MKV -> BIN
794    | PNG -> BIN    | PNG -> BIN
795      | GIF -> BIN
796      | MP3 -> BIN
797      | WMA -> BIN
798      | OGG -> BIN
799    | TEXTS -> TXT    | TEXTS -> TXT
800    | WML -> TXT    | WML -> TXT
801    
# Line 767  let ext_to_mime_type ext = Line 809  let ext_to_mime_type ext =
809    | JAVASCRIPT -> "text/javascript"    | JAVASCRIPT -> "text/javascript"
810    | JPEG -> "image/jpg"    | JPEG -> "image/jpg"
811    | MPEG -> "video/mpeg"    | MPEG -> "video/mpeg"
812      | AVI -> "video/x-msvideo"
813      | WMV -> "video/x-ms-wmv"
814      | ASF -> "video/x-ms-asf"
815      | MOV -> "video/quicktime"
816      | OGM -> "application/ogg" (* is that correct ? *)
817      | RM -> "audio/x-pn-realaudio"
818      | MKV -> "video/x-matroska" (* is that correct ? *)
819    | PNG -> "image/png"    | PNG -> "image/png"
820      | GIF -> "image/gif"
821      | MP3 -> "audio/mpeg"
822      | WMA -> "audio/x-ms-wma"
823      | OGG -> "application/ogg" (* is that correct ? *)
824    | TEXTS -> "text/plain"    | TEXTS -> "text/plain"
825    | WML -> "text/vnd.wap.wml"    | WML -> "text/vnd.wap.wml"
826    
# Line 832  let http_add_bin_header r ext clen = Line 885  let http_add_bin_header r ext clen =
885    http_add_bin_info_header r clen;    http_add_bin_info_header r clen;
886    add_gzip_headers r    add_gzip_headers r
887    
888    let http_add_bin_stream_header r ext =
889      http_file_type := BIN;
890      http_add_gen_header r;
891      let mime_type = ext_to_mime_type ext in
892      let mime_type = if mime_type <> "" then mime_type
893      else "application/binary" in
894      add_reply_header r "Content-Type" mime_type;
895      add_reply_header r "Accept-Ranges" "bytes"
896    
897  let http_send_bin r buf filename =  let http_send_bin r buf filename =
898    let file_to_send = File.to_string filename in    let file_to_send = File.to_string filename in
899    let clen = String.length file_to_send in    let clen = String.length file_to_send in
# Line 1351  let http_handler o t r = Line 1413  let http_handler o t r =
1413                            (Int64.to_string size);                            (Int64.to_string size);
1414                          zero, size                          zero, size
1415                    in                    in
1416                        
1417                    add_reply_header r "Content-type" "application/binary";                    let filename = file_best_name file in
1418                    add_reply_header r "Accept-Ranges" "bytes";                    let exten = Filename2.last_extension filename in
1419                      let len = String.length exten in
1420                      let exten = if len = 0 then exten
1421                          else String.lowercase (String.sub exten 1 (len - 1)) in
1422                      http_add_bin_stream_header r (extension_to_file_ext exten);
1423    
1424                    let s = String.create 200000 in                    let s = String.create 200000 in
1425                    set_max_output_buffer r.sock (String.length s);                    set_max_output_buffer r.sock (String.length s);
# Line 1441  let http_handler o t r = Line 1507  let http_handler o t r =
1507      | BIN -> Buffer.contents buf      | BIN -> Buffer.contents buf
1508      | UNK -> "Unknown type for content :" ^ (Buffer.contents buf)      | UNK -> "Unknown type for content :" ^ (Buffer.contents buf)
1509    in    in
1510    r.reply_content <- if !!html_use_gzip then Autoconf.zlib__gzip_string s else s    r.reply_content <-
1511        if !http_file_type <> BIN && !!html_use_gzip then
1512          Autoconf.zlib__gzip_string s
1513        else s
1514    
1515  let http_options = {  let http_options = {
1516      conn_buf = Buffer.create 10000;      conn_buf = Buffer.create 10000;

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26