25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Include Last-Modified HTTP header in responses to allow caching (EJAB-546) in mod_http_fileserver and mod_muc_log_http.

SVN Revision: 2174
This commit is contained in:
Badlop 2009-06-16 13:45:03 +00:00
parent b416ed03c9
commit a9ab002f48

View File

@ -8,8 +8,6 @@
-module(mod_http_fileserver).
-author('mmirra@process-one.net').
-define(ejabberd_debug, true).
-compile([export_all]).
-behaviour(gen_mod).
@ -17,6 +15,7 @@
start/2,
stop/1,
process/2,
loop/1,
ctl_process/2
]).
@ -24,6 +23,7 @@
-include("jlib.hrl").
-include("ejabberd_http.hrl").
-include("ejabberd_ctl.hrl").
-include_lib("kernel/include/file.hrl").
%%%----------------------------------------------------------------------
%%% REQUEST HANDLERS
@ -71,6 +71,7 @@ serve(LocalPath) ->
?DEBUG("Delivering content.", []),
{200,
[{"Server", "ejabberd"},
{"Last-Modified", last_modified(FileName)},
{"Content-type", content_type(FileName)}],
FileContents};
{error, Error} ->
@ -131,6 +132,11 @@ content_type(Filename) ->
_Else -> "application/octet-stream"
end.
last_modified(FileName) ->
{ok, FileInfo} = file:read_file_info(FileName),
Then = FileInfo#file_info.mtime,
httpd_util:rfc1123_date(Then).
open_file(Filename) ->
case file:open(Filename, [append]) of
{ok, File} ->