mirror of
https://github.com/processone/ejabberd.git
synced 2024-07-21 00:19:53 +02:00
mod_http_fileserver.erl will only conditionally gzip content by checking Accept-Encoding.
This commit is contained in:
parent
7ef85dddea
commit
062d58026a
|
@ -199,7 +199,8 @@ process(LocalPath, Request) ->
|
||||||
CustomHeaders = conf_get(Host, custom_headers, undefined),
|
CustomHeaders = conf_get(Host, custom_headers, undefined),
|
||||||
DefaultContentType = conf_get(Host, default_content_type, undefined),
|
DefaultContentType = conf_get(Host, default_content_type, undefined),
|
||||||
ContentTypes = conf_get(Host, content_types, undefined),
|
ContentTypes = conf_get(Host, content_types, undefined),
|
||||||
Static = conf_get(Host, serve_gzip, undefined),
|
Encoding = conf_get(Host, serve_gzip, undefined),
|
||||||
|
Static = select_encoding(ClientHeaders, Encoding),
|
||||||
DocRoot = conf_get(Host, docroot, undefined),
|
DocRoot = conf_get(Host, docroot, undefined),
|
||||||
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
||||||
{FileSize, Code, Headers, Contents} = case file:read_file_info(FileName) of
|
{FileSize, Code, Headers, Contents} = case file:read_file_info(FileName) of
|
||||||
|
@ -247,6 +248,16 @@ modified(FileInfo, LastModified)->
|
||||||
?DEBUG("Modified : ~p > ~p (serving: ~p)", [Mtime, AfterDate,Mtime > AfterDate]),
|
?DEBUG("Modified : ~p > ~p (serving: ~p)", [Mtime, AfterDate,Mtime > AfterDate]),
|
||||||
Mtime > AfterDate.
|
Mtime > AfterDate.
|
||||||
|
|
||||||
|
select_encoding(_Headers, false)->
|
||||||
|
false;
|
||||||
|
select_encoding(Headers, Configuration)->
|
||||||
|
Value = find_header('Accept-Encoding', Headers, ""),
|
||||||
|
Schemes = string:tokens(Value, ","),
|
||||||
|
case lists:member("gzip",Schemes) of
|
||||||
|
true -> Configuration;
|
||||||
|
false -> false
|
||||||
|
end.
|
||||||
|
|
||||||
%% Troll through the directory indices attempting to find one which
|
%% Troll through the directory indices attempting to find one which
|
||||||
%% works, if none can be found, return a 404.
|
%% works, if none can be found, return a 404.
|
||||||
serve_index(_FileName, [], _CH, _DefaultContentType, _ContentTypes, _Static) ->
|
serve_index(_FileName, [], _CH, _DefaultContentType, _ContentTypes, _Static) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user