Feature #786
closedmod_cml + mod_compress NOT A DREAM ANYMORE
Description
lighttpd developers hello, again.
I use lighttpd-1.4.11 in production with mod_cml.
Like before, when i need "Expires", this time i needed to send the "output_include" from lua through the mod_staticfile because i wanted support from mod_compress.
this code only works if you have 1 output_include file.
to tell the difference between 1 and more files i told the code to make the difference
based on "string" or "table".
Lua Programming:
use: ''output_include = '''(''' "somefilename.html" ''')_'_'[BR]
instead of: ''output_include = { "somefilename.html" }''
this will make it go through mod_staticfile (and if you have mod_compress, then magic will happen ;)
here is the code:
(place it right before starting the loop through the output_include table)
[
tags/lighttpd-1.4.11/src/mod_cml_lua.c:313¶
]
if (0 == lua_to_c_get_string(L, "output_include", b)) { /* yep we are a string !!! */ buffer *b_ = buffer_init(); stat_cache_entry *sce = NULL; const char *s = b->ptr; /* the file is relative, make it absolute */ if (s[0] != '/') { buffer_copy_string_buffer(b_, p->basedir); buffer_append_string_buffer(b_, b); } else { buffer_copy_string_buffer(b_, b); } if (HANDLER_ERROR == stat_cache_get_entry(srv, con, b_, &sce)) { /* stat failed */ switch(errno) { case ENOENT: /* a file is missing, call the handler to generate it */ if (!buffer_is_empty(p->trigger_handler)) { ret = 1; /* cache-miss */ log_error_write(srv, __FILE__, __LINE__, "s", "a file is missing, calling handler"); break; } else { /* handler not set -> 500 */ ret = -1; log_error_write(srv, __FILE__, __LINE__, "s", "a file missing and no handler set"); break; } break; default: break; } } else { /* tell the server to handle this file through mod_staticfile */ buffer_reset(con->uri.path); buffer_reset(con->physical.path); buffer_copy_string(con->uri.path, ""); buffer_copy_string_buffer(con->physical.path, b); con->mode = DIRECT; return HANDLER_GO_ON; } }
thanks,
-- amix.
-- duke.amix
Updated by Anonymous over 18 years ago
i forgot to add this at the end of the code block,
buffer_free(b_);
thanks,
-- amix.
-- duke.amix
Updated by Anonymous over 18 years ago
hey all,
im sorry but the above code will cause a memory leak.
here is the fix, insert it after '_'con->mode = DIRECT;'__* and before *return HANDLER_GO_ON;'_'
buffer_free(b_); buffer_free(b); stream_close(&rm.st); lua_close(L);
thanks,[BR]
-- amix.
Updated by stbuehler over 16 years ago
- Status changed from New to Fixed
- Resolution set to wontfix
mod_cml is deprecated
Updated by gstrauss about 1 year ago
- Description updated (diff)
- Status changed from Wontfix to Fixed
- ASK QUESTIONS IN Forums set to No
mod_cml is no longer part of the lighttpd base
For replacement, see lua mod_cml
For much more powerful features, review all the features of mod_magnet
mod_compress was replaced with mod_deflate in lighttpd, and mod_deflate runs after mod_magnet (No tricks are needed with mod_magnet and mod_deflate, unlike mod_compress.)
lua mod_staticfile is a good example as a starting point. Then, configure mod_deflate and enjoy.
Also available in: Atom