X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fimage.ml;h=90d0a5acb86926a1a8861f98703e75fd5e38fff9;hb=a91aac39ca718af3ad1f446742c3d200da60f4b6;hp=bfffbfd1f241a13c1c6ac3549c67d1a000cf8d0e;hpb=1e757a53a78e6b288f483b3b689a600d20575562;p=cocanwiki.git diff --git a/scripts/image.ml b/scripts/image.ml index bfffbfd..90d0a5a 100644 --- a/scripts/image.ml +++ b/scripts/image.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: image.ml,v 1.9 2004/10/23 12:00:23 rich Exp $ + * $Id: image.ml,v 1.12 2004/10/28 14:51:03 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,10 +50,13 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = sth#execute args; let data, mime_type, deleted = - match sth#fetch1 () with - [ `Binary data; `String mime_type; `Bool deleted ] -> - data, mime_type, deleted - | _ -> assert false in + try + (match sth#fetch1 () with + [ `Binary data; `String mime_type; `Bool deleted ] -> + data, mime_type, deleted + | _ -> assert false) + with + Not_found -> raise (HttpError cHTTP_NOT_FOUND) in (* If deleted, refuse to serve this image except if called from the * deleted images page. @@ -65,13 +68,14 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = try String.find referer "/_images?deleted"; true with String.Invalid_string -> false in - if not ok then - failwith "image.ml: bandwidth theft avoided" + if not ok then ( + prerr_endline "image.ml: bandwidth theft avoided"; + raise (HttpError cHTTP_NOT_FOUND) + ) ); - if version <> None then - (* Set a medium-length expiry time on this resource. *) - Table.set (Request.headers_out r) "Expires" (Expires.medium ()); + (* Set a medium-length expiry time on this resource. *) + Table.set (Request.headers_out r) "Expires" (Expires.medium ()); (* Content-length header. *) Table.set (Request.headers_out r) "Content-Length"