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