lighty.c.header_tokens convenience func to create a sequence table
of tokens parsed from a given string, e.g. an HTTP header. The purpose
of this routine is to made it easier to properly parse an HTTP header
into tokens since token separators can be part of quoted-strings, and
they are not token separators when part of quoted strings.
The sequence table t returned from lighty.c.header_tokens() can be
walked with:
for i = 1, #t do
-- <body here>
end
While walking, each element can be passed to lighty.c.quoteddec()
to decode, as non-quoted-string elements are returned as-is.
Note: lighty.c.header_tokens() returns a sequence table,
which is different from lighty.c.cookie_tokens(),
which returns a key/value table of cookies.
(thx dirk4000)
Storing the config list into a data structure with case-insensitive keys
meant that if the config list contained multiple entries which differed
in case-only, then only one entry would survive. Case-sensitivity of
username matters for HTTP Digest auth. Store config list in value list.
x-ref:
"mod_auth (configuration): Change of behavior in user name handling"
https://redmine.lighttpd.net/boards/2/topics/10275
fix header,content legacy table clear/reset
(regression since lighttpd 1.4.60)
(newer mod_magnet interfaces in lighttpd 1.4.60 should be preferred
over legacy lighty.header and lighty.content tables)
Lua does not provide an easy way to (always) get num table elements.
lua_rawlen() is usable only on tables created as a sequence table;
lua_rawlen() might return any lua table "edge", including 0, for other
tables, even if those tables contain entries. lua_next() must be used
to walk lua tables.
lighty.c.quotedenc() and lighty.c.quoteddec() convenience functions
to encode and decode MIME quoted-string, e.g. quoted-string formats
in HTTP headers.
Prefer r->tmp_buf with lua 5.3+ where r->tmp_buf is quick to access.
Otherwise use chunk_buffer_acquire()/chunk_buffer_release(), which
is also quick, but may be slightly slower.
If an HTTP/1.1 request is configured to force an HTTP/1.0 response
(server.protocol-http11 = "disable"), then also disable keep-alive
(which is enabled by default in HTTP/1.1). This overrides the
request header Connection: keep-alive (not re-validated), which is
unlikely to be sent with an HTTP/1.1 request.
reset after error raised attaching content
(The lua stack has been unwound after the exception)
(Might avoid reloading script if an alt env is used; not tested)
chunkqueue_chunk_file_view()
reduces size of struct chunk
use mmap with mod_deflate libdeflate, if mmap available,
even when lighttpd not built with --enable-mmap
avoid using mmap on temp files in chunkqueue (c->file.is_temp)
since pread() with a reasonable block size is typically as fast
or faster than mmap on files read sequentially and used only once,
especially when writing results to limited-size socket buffers
(and lighttpd temp files are, in most cases, by default about 1 MB)
(Exception: sometimes mmap is used for convenience or to fulfill
a requirement, e.g. one-shot libdeflate in mod_deflate)
(There are many factors which influence speed of mmap versus pread,
so this should not be construed as generic usage advice.)
check lighty.result.content exists before setjmp() to avoid setjmp()
overhead if there is no content set via lua lighty.result.content
(response body could have been set via lua lighty.r.resp_body.* instead)
configure --with-libdeflate option to use libdeflate
(must also configure --enable-mmap for mod_deflate to use libdeflate
on input files larger than 64kB; libdeflate not used on files <= 64kB)
server.feature-flags += ( "http10.range" => "enable" )
The Range request header is HTTP/1.1, not HTTP/1.0.
Intermediate HTTP/1.0 proxies might mishandle or incorrectly cache
responses to HTTP/1.1 Range requests, so the default in lighttpd is
to ignore Range requests sent with HTTP/1.0.
This feature flag changes the default if an admin desires to support
dumb HTTP/1.0 clients that might (incorrectly) send Range requests
with HTTP/1.0. Those client really ought to grow HTTP/1.1 support:
add support to receive HTTP/1.1 Transfer-Encoding: chunked responses,
and then those client may safely send HTTP/1.1 Range requests
(and in many cases, also Connection: close).
(thx ryandesign)
There is no COPYFILE_CLONE_FORCE on OSX <10.12 so fall back to using
fcopyfile() to avoid race condition on source (if changed to dir) if
using copyfile() with flags equivalent to COPYFILE_CLONE_FORCE, but
without the 'force' flag.
x-ref:
"error: use of undeclared identifier 'COPYFILE_CLONE_FORCE'"
https://redmine.lighttpd.net/issues/3142