Commit Graph

3505 Commits (e6a87a894d1b88301e59ab4b38718393d5e5bdd9)

Author SHA1 Message Date
Glenn Strauss d8b88be056 [core] move connections_get_state to connections.c
connections_get_state() is used only in connections.c for debugging
2020-10-11 11:43:06 -04:00
Glenn Strauss 0f9ec8b755 [mod_status] dedicated funcs for r->state labels
fork connection_get_state() for use by mod_status, which
might in the future choose to display different labels.
move and rename connection_get_short_state() into mod_status,
as the func is used only by mod_status

(connection_get_state() is currently used elsewhere only for debugging
 in connections.c)
2020-10-11 11:43:06 -04:00
Glenn Strauss 878073d1c9 [core] keep pool of (request_st *) for HTTP/2 2020-10-11 11:43:06 -04:00
Glenn Strauss 550609c8ae [core] request_acquire(), request_release()
continue code abstraction for (request_st *)
2020-10-11 11:43:06 -04:00
Glenn Strauss 0905b6f7f9 [core] fix 1-char trunc of default server.tag
(thx avij)
2020-10-11 11:43:06 -04:00
Glenn Strauss cf0098eac8 [mod_auth] fix crash if auth.require misconfigured (fixes #3023)
(thx veyrdite)

  "Segfault with mod_auth & htpasswd (lighttpd.conf misconfig)"
2020-10-11 11:43:06 -04:00
Glenn Strauss cae205ad99 [build] fix meson build 2020-10-11 11:43:06 -04:00
Glenn Strauss 79e2f5baee [core] ignore empty field-name from backends
Empty field-name is already ignored when generating response headers,
but this is an explicit skip of empty field-name sent from backends,
including field-names that look like HTTP/2 pseudo-headers, as those
begin with ':'.
2020-10-11 11:43:06 -04:00
Glenn Strauss 8e2cf55250 [core] redirect to dir using relative-path
Location response header is permitted to use relative-path in
RFC 7231 Section 7.1.2. Location

Prefer relative path in redirection for the benefit of reverse proxies
and CDNs.  Doing so also avoids potentially disclosing internal schemes
and server names which client might not be able to directly reach.

To restore prior behavior of sending a fully-qualified absolute URI:
server.feature-flags += ("absolute-dir-redirect" => "enable")

2020-10-11 11:43:06 -04:00
Glenn Strauss baa651a3ab [mod_status] adjust to print HTTP/2 requests 2020-10-11 11:43:06 -04:00
Glenn Strauss 9d74aa600b [mod_status] separate funcs to print request table 2020-10-11 11:43:06 -04:00
Glenn Strauss 06df2716f2 [core] comment possible future ls-hpack optimize 2020-10-11 11:43:06 -04:00
Glenn Strauss 8fc8ab891a [core] http_request_parse_header() specialized
http_request_parse_header() specialized for HTTP/2 request headers
to be parsed as each field-name and value is HPACK-decoded; send headers
directly from HPACK decoder, rather than double-buffering in chunkqueue

http_request_headers_process_h2() for post-processing
2020-10-11 11:43:06 -04:00
Glenn Strauss ada09a23b0 [core] h2_send_headers() specialized for resp hdrs
specialized version of http_response_write_header(); send headers
directly to HPACK encoder, rather than double-buffering in chunkqueue
2020-10-11 11:43:06 -04:00
Glenn Strauss 014e5240ef [core] HTTP/2 HPACK using LiteSpeed ls-hpack
2020-10-11 11:43:06 -04:00
Glenn Strauss 70b1af0640 [core] link in ls-hpack (EXPERIMENTAL)
LiteSpeed ls-hpack v2.2.1

XXX: might be better to include this as a git submodule
but minor code changes were made here for portability:
- C99 flexible array members defined as a[] instead of a[0])
- pedantic compiler warnings (excess ';' and missing declarations)
- deletion of large tables from ls-hpack/huff-tables.h (code size)
2020-10-11 11:43:06 -04:00
Glenn Strauss 1bf4555800 [core] update comment 2020-10-11 11:43:06 -04:00
Glenn Strauss 501182dc4b [core] adjust (disabled) debug code 2020-10-11 11:43:06 -04:00
Glenn Strauss 1c7c19a9d5 [core] skip write throttle for 100 Continue
(small code simplification)
2020-10-11 11:43:06 -04:00
Glenn Strauss 6fc8ad3194 [core] discard 100 102 103 responses from backend 2020-10-11 11:43:06 -04:00
Glenn Strauss 4d9c54f61b [core] mark some error paths with attribute cold 2020-10-11 11:43:06 -04:00
Glenn Strauss 8d7e9439b5 [core] connection transition to HTTP/2; incomplete

(basic framework with some stub functions; incomplete)
(subsequently incrementally updated using git rebase)

HTTP/2 via TLS ALPN extension  (TLS)
HTTP/2 via Upgrade: h2c        (cleartext)
HTTP/2 via Prior Knowledge     (cleartext)

server.feature-flags += ("server.h2proto" => "enable")
to enable HTTP/2
server.feature-flags += ("server.h2c" => "enable")
to enable upgrade to HTTP/2 over cleartext http
2020-10-11 11:43:06 -04:00
Glenn Strauss 784f1ac1da [core] alternate between two joblists
process one joblist and queue work up on second joblist

loop to poll, but poll immediate if work was queued on second joblist
2020-10-11 11:43:06 -04:00
Glenn Strauss 6eca864c5e [core] h2.[ch] with stub funcs (incomplete)
(subsequently incrementally updated using git rebase)

huge props and many thank yous to writers of testing tools used while
developing HTTP/2 support in lighttpd:

  h2spec - conformance testing tool for HTTP/2 implementation
  h2load - HTTP/2 benchmarking tool
  curl   - command line tool and library for transferring data with URLs
2020-10-11 11:43:02 -04:00
Glenn Strauss 2c8f1b4621 [core] isolate more resp code in response.c
http_response_handler() and response generation flow control logic
2020-10-03 09:05:39 -04:00
Glenn Strauss 2f2eec18fb [multiple] isolate more con code in connections.c
move code from connections-glue.c back into connections.c

move code from connections-glue.c to http-header-glue.c
  rename connection_response_reset()
      to http_response_reset()
  rename connection_handle_read_post_error()
      to http_response_reqbody_read_error()
2020-10-03 09:05:38 -04:00
Glenn Strauss 8940fec894 [multiple] modules read reqbody via fn ptr
r->con->reqbody_read() replaces connection_handle_read_post_state()

future: might provide different callbacks for request body with
Content-Length versus request body sent via Transfer-Encoding: chunked
2020-10-03 09:05:38 -04:00
Glenn Strauss 4e4026703d [core] reqpool.[ch] for (request_st *)
move request_init() request_reset() request_free() from connections.c
2020-10-03 09:05:38 -04:00
Glenn Strauss 6971c6c811 [core] move http_request_headers_process()
move http_request_headers_process() to request.[ch]
2020-10-03 09:05:38 -04:00
Glenn Strauss db7b51a4f6 [core] http_header_parse_hoff()
moved and renamed from connections.c:connection_read_header_hoff()
2020-10-03 09:05:38 -04:00
Glenn Strauss 89b3d73daa [core] adjust http_request_headers_process()
adjust for code reuse, and moving routine to lower-level file
2020-10-03 09:05:38 -04:00
Glenn Strauss 517e32785e [core] HTTP2-Settings 2020-10-03 09:05:38 -04:00
Glenn Strauss 4e656f5354 [core] connection_set_fdevent_interest()
extracted from connection_state_machine() (for reuse)

include interest for POLLRDHUP unless already received
2020-10-03 09:05:38 -04:00
Glenn Strauss d4937e29f1 [mod_accesslog,mod_rrdtool] HTTP/2 basic accounting
Note: rrdtool counts do not include HTTP/2 protocol overhead.
Continue to count mod_rrdtool per request rather than per connection
so that data is updated after each request, rather than aggregated
to the end of a potentially long-lived connection with many keep-alives.
2020-10-03 09:05:38 -04:00
Glenn Strauss afc2025d8e [core] reset connection counters per connection
reset connection counters per connection, not per request

adjust mod_accesslog and mod_rrdtool usage

continue to count mod_rrdtool per request rather than per connection
so that data is updated after each request, rather than aggregated
to the end of a potentially long-lived connection with many keep-alives.
2020-10-03 09:05:38 -04:00
Glenn Strauss 8eea3bd014 [core] connection_state_machine_loop()
extracted from connection_state_machine() (for reuse)
2020-10-03 09:05:38 -04:00
Glenn Strauss 68dd6312a2 [core] request_headers_process()
extract code from connection_handle_read_state() for future reuse
2020-10-03 09:05:38 -04:00
Glenn Strauss f37c90bccc [core] parse h2 pseudo-headers 2020-10-03 09:05:38 -04:00
Glenn Strauss 4c699be6c6 [core] recognize status: 421 Misdirected Request 2020-10-03 09:05:38 -04:00
Glenn Strauss 77057a7c02 [core] lowercase response hdr field names for h2 2020-10-03 09:05:38 -04:00
Glenn Strauss e089facf84 [core] do not send Connection: close if h2 2020-10-03 09:05:38 -04:00
Glenn Strauss 21987c863f [mod_extforward] preserve changed addr for h2 con
Preserve changed addr for lifetime of h2 connection; upstream proxy
should not reuse same h2 connection for requests from different clients
2020-10-03 09:05:38 -04:00
Glenn Strauss bbcc2f229a [multiple] allow TLS ALPN "h2" if "server.h2proto" 2020-10-03 09:05:38 -04:00
Glenn Strauss a8f8d5edc0 [core] HTTP_VERSION_2 2020-08-13 15:05:25 -04:00
Glenn Strauss 1041a56dd9 [core] server.feature-flags to enable h2
server.feature-flags = ("server.h2proto" => "enable") to enable h2
2020-08-13 15:05:25 -04:00
Glenn Strauss 96324fbba0 [mod_extforward] skip after HANDLER_COMEBACK
do not re-run mod_extforward uri handler after HANDLER_COMEBACK

add some additional comments
2020-08-13 15:05:25 -04:00
Glenn Strauss 0c7d250034 [mod_extforward] save proto per connection
Even though request headers are per-request, update the proto on the
connection level for trusted (proxy) clients.  Note: the proxy must use
each connection only for a single connection from a single client
(typically true in practice), and not for multiple clients.

proto was previously saved on connection level for mod_extforward with
HAProxy PROXY protocol, but did not occur with X-Forwarded-Proto or the
Forwarded request header with proto=...

Before this change, modules which returned HANDLER_COMEBACK could lose
HTTPS=on if the resulting request was for a backend such as mod_fastcgi.
This was reported in mod_rewrite, but could also affect mod_magnet if
MAGNET_RESTART_REQUEST, or mod_cgi with cgi.local-redir = "enable"

  "FastCGI behavior different when using rewrite?"
2020-08-13 13:05:12 -04:00
Glenn Strauss b600b75f20 [core] inline buffer_reset()
buffer_reset() is used on pre-allocated buffers, so remove NULL check
2020-08-10 20:05:02 -04:00
Glenn Strauss e1bb579361 [core] disperse settings.h to appropriate headers 2020-08-10 20:04:57 -04:00
Glenn Strauss 3e046ccabf [core] dlsym for FAMNoExists() for compat w/ fam
gamin should be used instead of fam; fam is no longer maintained

This patch makes it safe to build lighttpd with gamin, but run on
systems with the (deprecated) fam installed, which can happen due
to historical package dependency declarations on some platforms
(Debian, Ubuntu).

gamin and fam are not 100% binary compatible.
(Among other things, fam does not provide FAMNoExists())

  "llibgamin vs libfam conflict solving"
  "libgamin0: libfam shlib dependency wrongly set to libfam0"
  "undefined symbol: FAMNoExists"
2020-08-10 15:56:28 -04:00