diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-12-12 10:42:29 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-12-12 10:45:21 -0500 |
commit | 0ba74e23816b9d844944f90b85e6c448864dfcdc (patch) | |
tree | a96aa9a03c2613c9c036601e9524f75ec31b0722 /src | |
parent | 96fd7e5d04d4e5cb609c876eae4176aa6cf2d7a5 (diff) | |
download | lighttpd-git-0ba74e23816b9d844944f90b85e6c448864dfcdc.tar.gz |
[mod_magnet] interface to http_response_send_file
st = lighty.c.stat("/path/to/file")
if (st and st.is_file) then
return st["http-response-send-file"]
end
calls http_response_send_file(), providing similar behavior as
mod_staticfile, including handling HTTP conditional requests
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_magnet.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mod_magnet.c b/src/mod_magnet.c index c99db4dc..733e52fe 100644 --- a/src/mod_magnet.c +++ b/src/mod_magnet.c @@ -450,6 +450,13 @@ static int magnet_stat_field(lua_State *L) { lua_pushnil(L); return 1; } + case 'h': { /* http-response-send-file */ + if (0 != strcmp(k.ptr, "http-response-send-file")) break; + request_st * const r = magnet_get_request(L); + http_response_send_file(r, &sce->name, sce); + lua_pushinteger(L, r->http_status); + return 1; + } case 'i': /* is_* */ if (k.len < 4) break; switch (k.ptr[3]) { |