diff options
| -rw-r--r-- | src/ucs.ml | 10 | 
1 files changed, 7 insertions, 3 deletions
| @@ -36,6 +36,10 @@ let log req =            Printer.Calendar.sprint "%Y-%m-%d %H:%M:%S" @@ Calendar.now ()) in    Lwt_io.printlf "[%s] %s" datetime (Uri.path uri) +let respond ?(mime="text/html; charset=utf-8") ?(status=`OK) body = +  let headers = Header.init_with "Content-Type" mime in +  Server.respond_string ~status ~body ~headers () +  let server =    let callback _conn req _body =      let meth = Request.meth req and @@ -48,9 +52,9 @@ let server =      | `GET, ["ics"; file] when Astring.String.is_suffix ~affix:".ics" file ->         let group = String.(sub file 0 (length file - 4)) in         fetch group >>= fun body -> -       let body = Ics.to_string @@ Course.decode body and -           headers = Header.init_with "Content-Type" "text/calendar" in -       Server.respond_string ~status:`OK ~body ~headers () +       Course.decode body +       |> Ics.to_string +       |> respond ~mime:"text/calendar; charset=utf-8"      | `GET, _ ->         Server.respond_string ~status:`Not_found ~body:"Not found\n" ()      | _ -> | 
