Commit Graph

4631 Commits (0b49e767b906d6861f63d3764001bd73a65265dc)

Author SHA1 Message Date
Glenn Strauss 1b56d7cf5b [mod_magnet] lighty.c.header_tokens convenience fn
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>
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.
2022-02-21 03:24:43 -05:00
Glenn Strauss 94c952bd1c [mod_magnet] magnet_push_quoted_string shared code
(internal) magnet_push_quoted_string() shared code
2022-02-21 01:20:05 -05:00
Glenn Strauss b03fcc7025 [doc] NEWS 2022-02-20 13:44:07 -05:00
Glenn Strauss 8b29653131 [mod_auth] save letter-case diff in require config
(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.

  "mod_auth (configuration): Change of behavior in user name handling"
2022-02-19 17:12:22 -05:00
Glenn Strauss 3ee5b84017 [mod_wolfssl] wolfssl v5.0.0 defines DH_set0_pqg() 2022-02-19 04:38:29 -05:00
Glenn Strauss 96557115cb [core] isolate plugins_*() funcs to main server
(future: might rename plugin.c -> plugins.c since the functions
 contained within are all plugins_*())
2022-02-19 03:52:17 -05:00
Glenn Strauss cc65a21e12 [mod_cgi] cgi.local-redir request_reset thru fnptr
cgi.local-redir call plugins_request_reset through fn ptr

(isolate plugins_* funcs to server;
 should not be called directly from plugins/modules)
2022-02-19 03:52:17 -05:00
Glenn Strauss 29bff8a516 [mod_magnet] fix header,content legacy table clear
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.
2022-02-19 03:52:15 -05:00
Glenn Strauss 85875e7022 [mod_magnet] lighty.c.quotedenc(),dec() funcs
lighty.c.quotedenc() and lighty.c.quoteddec() convenience functions
to encode and decode MIME quoted-string, e.g. quoted-string formats
in HTTP headers.
2022-02-19 02:40:37 -05:00
Glenn Strauss 072edb9dd8 [mod_magnet] magnet_tmpbuf_acquire(),release()
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.
2022-02-19 02:40:37 -05:00
Glenn Strauss 9727eb1768 [mod_magnet] adjust magnet_lighty_result_get()
rarely used
  e.g. if indexing into the content table before assigning a table
2022-02-19 02:40:37 -05:00
Glenn Strauss 23a5107232 [mod_magnet] remove duplicated NULL checks 2022-02-19 02:40:37 -05:00
Glenn Strauss 36e81d7d7f [mod_magnet] fix lighty.c.urldec_query()
(did not previously work)
2022-02-19 02:40:37 -05:00
Glenn Strauss ef0fe03f2b [mod_magnet] fix lighty.c.cookie_tokens()
(did not previously work)
2022-02-19 02:40:37 -05:00
Glenn Strauss cebe2b004c [mod_magnet] use lua_isnoneornil() in interfaces
prefer lua_isnoneornil() to lua_isnil() in C funcs backing lighty.c.*
2022-02-19 02:40:37 -05:00
Glenn Strauss ce360dc6ce [mod_magnet] clear stack when reloading script 2022-02-19 02:40:37 -05:00
Glenn Strauss 40437cef34 [mod_magnet] clear and reuse script-env table
clear and reuse script-env table for script invocations
2022-02-19 02:40:37 -05:00
Glenn Strauss 897b6e664e [mod_magnet] pass lighty table index, defer pops 2022-02-19 02:40:37 -05:00
Glenn Strauss 9e1acfa639 [doc] update external links 2022-02-19 02:40:37 -05:00
Glenn Strauss 95f04a89dd [mod_magnet] keep message handler on stack
keep lua_pcall message handler func (errfunc) on stack for reuse
rather than insert and remove each invocation.
2022-02-19 02:40:37 -05:00
Glenn Strauss de48eaa47e [core] fall back to getauxval(AT_RANDOM), if avail
fall back to use getauxval(AT_RANDOM), if available, for srand() init

getauxval(AT_RANDOM) is a glibc extension
2022-02-19 02:40:37 -05:00
Glenn Strauss 1db7f45e53 [mod_magnet] use lua_getextraspace() to store r
use lua_getextraspace() to store (request_st *)r with lua 5.3+
2022-02-19 02:40:37 -05:00
Glenn Strauss e4d31e1b68 [core] disable keep-alive if forcing HTTP/1.0 resp
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.
2022-02-19 02:40:37 -05:00
Glenn Strauss 2d1b16721c [core] chunk_file_pread() to wrap pread() 2022-02-19 02:40:37 -05:00
Glenn Strauss a2aaf45b7a [mod_magnet] use type returned from lua_getfield()
use type returned from lua_getfield() and lua_getglobal() in lua 5.3+
(remove extra call to lua_type())
2022-02-19 02:40:37 -05:00
Glenn Strauss d79779d830 [mod_magnet] collect chk for magnet lua_State init 2022-02-19 02:40:37 -05:00
Glenn Strauss 647a2a9a25 [mod_magnet] adjust hot path for more inlining 2022-02-19 02:40:37 -05:00
Glenn Strauss 610e885718 [mod_mbedtls] use newer mbedtls 3.2.0+ interfaces 2022-02-19 02:40:37 -05:00
Glenn Strauss 2f13190b58 [mod_magnet] lua_tointegerx() avoids raising error
use lua_tointegerx() instead of luaL_optinteger() to avoid raising error
(lua_tointegerx() was introduced in lua 5.2; fallback provided for <5.2)
2022-02-19 02:40:37 -05:00
Glenn Strauss 5c9eb60c8c [mod_magnet] reset after error attaching content
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)
2022-02-19 02:40:37 -05:00
Glenn Strauss d0273c8af5 [mod_magnet] defer req_env init unless needed
defer req_env initialization unless req_env might be needed by script
2022-02-19 02:40:37 -05:00
Glenn Strauss a162fc70e9 [core] prep server_tag at startup for h2 resp hdr 2022-02-19 02:40:37 -05:00
Glenn Strauss 14e5404af9 [mod_deflate] improve loop compressing file chunk 2022-02-19 02:40:37 -05:00
Glenn Strauss 129cbc1ef9 [mod_deflate] use pread if available 2022-02-19 02:40:37 -05:00
Glenn Strauss e05ce80502 [multiple] shared code for struct chunk and mmap

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.)
2022-02-19 02:40:37 -05:00
Glenn Strauss 9b55ac6da5 [multiple] pedantic chunk.c checks for 0-len chunk 2022-02-19 02:40:37 -05:00
Glenn Strauss 6cd3b5f8af [multiple] use new sys_setjmp_eval3() interface
wrap system os setjmp or compiler try/catch and access mmap inside
callback to protect against SIGBUS (or _WIN32 EXCEPTION_IN_PAGE_ERROR)
2022-02-19 02:40:34 -05:00
Glenn Strauss a314b8d031 [core] network_write_file_chunk_remap separate fn 2022-02-19 02:37:06 -05:00
Glenn Strauss 6eeb45f1f9 [core] include guard consistency in sys-time.h
include guard consistency with other lighttpd sys-*.h headers
2022-02-19 02:37:06 -05:00
Glenn Strauss 6d5ecb6155 [mod_magnet] check lighty.result.content b4 setjmp
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)
2022-02-19 02:37:06 -05:00
Glenn Strauss 9357da4126 [core] sys-setjmp.[ch]
wrap system setjmp or compiler C try/catch mechanism
2022-02-19 02:37:01 -05:00
Glenn Strauss d662fae369 [mod_deflate] mark input bytes const 2022-02-14 03:41:24 -05:00
Glenn Strauss d68fc6394f [mod_deflate] --with-libdeflate to use libdeflate
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)
2022-02-14 03:41:24 -05:00
Glenn Strauss 46110127f7 [mod_deflate] prototype using libdeflate w/ mmap 2022-02-14 03:41:24 -05:00
Glenn Strauss a78f447c35 [mod_deflate] collect mmap code
mmap entire file to compress on 64-bit systems
2022-02-09 19:29:04 -05:00
Glenn Strauss bfa89204f4 [mod_mbedtls] set usekeysize for mbedtls 3.2.0+ 2022-02-05 16:36:33 -05:00
Glenn Strauss 25f83b84b6 [core] feature flag to allow Range w/ HTTP/1.0
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).
2022-02-05 16:36:33 -05:00
Glenn Strauss 422d0355f5 [core] Illumos epoll incompatible w/ lighttpd impl
Illumos POLLRDHUP != EPOLLRDHUP; lighttpd implementation asserts()
(since lighttpd implementation defines FDEVENT_RDHUP as POLLRDHUP)
2022-02-01 12:26:36 -05:00
Glenn Strauss 2759d1eb00 [mod_deflate] fix to return 304 with If-None-Match (fixes #3143)
(thx meier22)

Bug in lighttpd 1.4.51 - lighttpd 1.4.64

  "mod_deflate not returning 304 Not Modified for If-None-Match request"
  "How to get 304 Not Modified - response with mod_deflate"
2022-01-30 11:03:32 -05:00
Glenn Strauss 4432e34253 [mod_webdav] no COPYFILE_CLONE_FORCE on OSX <10.12 (fixes #3142)
(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.

  "error: use of undeclared identifier 'COPYFILE_CLONE_FORCE'"
2022-01-24 16:07:49 -05:00