Browse Source

backport mod_deflate to lighttpd 1.4 (fixes #1824, fixes #2753)

lots of fixes and improvements

limitations: see comments at top of mod_deflate.c

missing functionality: encode streaming response
  (module currently requires response be collected before being sent)

potential functionality: addition of compressed file cache would
  allow mod_deflate to fully supplant mod_compress in lighttpd 1.4.x

x-ref:
  "Adding mod_deflate to 1.4.xx"
  https://redmine.lighttpd.net/issues/1824
  "mod_deflate backport compile error if ENABLE_MMAP not defined"
  https://redmine.lighttpd.net/issues/2753

github: closes #67
personal/stbuehler/mod-csrf-old
Glenn Strauss 6 years ago
parent
commit
cb1a3c6299
  1. 2
      configure.ac
  2. 3
      src/CMakeLists.txt
  3. 6
      src/Makefile.am
  4. 1
      src/SConscript
  5. 10
      src/connections.c
  6. 1203
      src/mod_deflate.c
  7. 3
      src/plugin.c
  8. 2
      src/plugin.h

2
configure.ac

@ -871,7 +871,7 @@ AC_OUTPUT
do_build="mod_cgi mod_fastcgi mod_extforward mod_proxy mod_evhost mod_simple_vhost mod_access mod_alias mod_setenv mod_usertrack mod_auth mod_status mod_accesslog"
do_build="$do_build mod_rrdtool mod_secdownload mod_expire mod_compress mod_dirlisting mod_indexfile mod_userdir mod_webdav mod_staticfile mod_scgi mod_flv_streaming mod_ssi"
do_build="$do_build mod_rrdtool mod_secdownload mod_expire mod_compress mod_dirlisting mod_indexfile mod_userdir mod_webdav mod_staticfile mod_scgi mod_flv_streaming mod_ssi mod_deflate"
plugins="mod_rewrite mod_redirect mod_trigger_b4_dl"
features="regex-conditionals"

3
src/CMakeLists.txt

@ -567,6 +567,7 @@ if(NOT WIN32)
endif()
add_and_install_library(mod_cml "mod_cml.c;mod_cml_lua.c;mod_cml_funcs.c")
add_and_install_library(mod_compress mod_compress.c)
add_and_install_library(mod_deflate mod_deflate.c)
add_and_install_library(mod_dirlisting mod_dirlisting.c)
add_and_install_library(mod_evasive mod_evasive.c)
add_and_install_library(mod_evhost mod_evhost.c)
@ -683,8 +684,10 @@ target_link_libraries(mod_authn_ldap ${L_MOD_AUTHN_LDAP})
if(HAVE_ZLIB_H)
if(HAVE_BZLIB_H)
target_link_libraries(mod_compress ${ZLIB_LIBRARY} bz2)
target_link_libraries(mod_deflate ${ZLIB_LIBRARY} bz2)
else()
target_link_libraries(mod_compress ${ZLIB_LIBRARY})
target_link_libraries(mod_deflate ${ZLIB_LIBRARY})
endif()
endif()

6
src/Makefile.am

@ -257,6 +257,11 @@ mod_compress_la_SOURCES = mod_compress.c
mod_compress_la_LDFLAGS = $(common_module_ldflags)
mod_compress_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)
lib_LTLIBRARIES += mod_deflate.la
mod_deflate_la_SOURCES = mod_deflate.c
mod_deflate_la_LDFLAGS = $(common_module_ldflags)
mod_deflate_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)
lib_LTLIBRARIES += mod_auth.la
mod_auth_la_SOURCES = mod_auth.c
mod_auth_la_LDFLAGS = $(common_module_ldflags)
@ -338,6 +343,7 @@ lighttpd_SOURCES = \
mod_cgi.c \
mod_cml.c mod_cml_lua.c mod_cml_funcs.c \
mod_compress.c \
mod_deflate.c \
mod_dirlisting.c \
mod_evasive.c \
mod_expire.c \

1
src/SConscript

@ -98,6 +98,7 @@ modules = {
'mod_expire' : { 'src' : [ 'mod_expire.c' ] },
'mod_status' : { 'src' : [ 'mod_status.c' ] },
'mod_compress' : { 'src' : [ 'mod_compress.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] },
'mod_deflate' : { 'src' : [ 'mod_deflate.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] },
'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] },
'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] },
'mod_auth' : { 'src' : [ 'mod_auth.c' ] },

10
src/connections.c

@ -441,6 +441,16 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
break;
}
/* Allow filter plugins to change response headers before they are written. */
switch(plugins_call_handle_response_start(srv, con)) {
case HANDLER_GO_ON:
case HANDLER_FINISHED:
break;
default:
log_error_write(srv, __FILE__, __LINE__, "s", "response_start plugin failed");
return -1;
}
if (con->file_finished) {
/* we have all the content and chunked encoding is not used, set a content-length */

1203
src/mod_deflate.c

File diff suppressed because it is too large

3
src/plugin.c

@ -40,6 +40,7 @@ typedef enum {
PLUGIN_FUNC_HANDLE_SIGHUP,
PLUGIN_FUNC_HANDLE_SUBREQUEST,
PLUGIN_FUNC_HANDLE_SUBREQUEST_START,
PLUGIN_FUNC_HANDLE_RESPONSE_START,
PLUGIN_FUNC_HANDLE_DOCROOT,
PLUGIN_FUNC_HANDLE_PHYSICAL,
PLUGIN_FUNC_CONNECTION_RESET,
@ -332,6 +333,7 @@ PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_REQUEST_DONE, handle_request_done)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_CONNECTION_CLOSE, handle_connection_close)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SUBREQUEST, handle_subrequest)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SUBREQUEST_START, handle_subrequest_start)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_RESPONSE_START, handle_response_start)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_DOCROOT, handle_docroot)
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_PHYSICAL, handle_physical)
PLUGIN_TO_SLOT(PLUGIN_FUNC_CONNECTION_RESET, connection_reset)
@ -462,6 +464,7 @@ handler_t plugins_call_init(server *srv) {
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SIGHUP, handle_sighup);
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SUBREQUEST, handle_subrequest);
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_SUBREQUEST_START, handle_subrequest_start);
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_RESPONSE_START, handle_response_start);
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_DOCROOT, handle_docroot);
PLUGIN_TO_SLOT(PLUGIN_FUNC_HANDLE_PHYSICAL, handle_physical);
PLUGIN_TO_SLOT(PLUGIN_FUNC_CONNECTION_RESET, connection_reset);

2
src/plugin.h

@ -53,6 +53,7 @@ typedef struct {
* has to be found
*/
handler_t (* handle_subrequest) (server *srv, connection *con, void *p_d); /* */
handler_t (* handle_response_start) (server *srv, connection *con, void *p_d); /* before response headers are written */
handler_t (* connection_reset) (server *srv, connection *con, void *p_d); /* */
void *data;
@ -67,6 +68,7 @@ handler_t plugins_call_handle_uri_raw(server *srv, connection *con);
handler_t plugins_call_handle_uri_clean(server *srv, connection *con);
handler_t plugins_call_handle_subrequest_start(server *srv, connection *con);
handler_t plugins_call_handle_subrequest(server *srv, connection *con);
handler_t plugins_call_handle_response_start(server *srv, connection *con);
handler_t plugins_call_handle_request_done(server *srv, connection *con);
handler_t plugins_call_handle_docroot(server *srv, connection *con);
handler_t plugins_call_handle_physical(server *srv, connection *con);

Loading…
Cancel
Save