+ let data, mime_type, deleted =
+ 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 file except if called from the site. *)
+ if deleted then (
+ let referer =
+ try Table.get (Request.headers_in r) "Referer" with Not_found -> "" in
+ let ok =
+ try String.find referer hostname; true
+ with String.Invalid_string -> false in
+
+ if not ok then (
+ prerr_endline "file.ml: bandwidth theft avoided";
+ raise (HttpError cHTTP_NOT_FOUND)
+ )
+ );