590 Commits

Author SHA1 Message Date
dd98030cb3 expand UNC checking
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1927033 13f79535-47bb-0310-9956-ffa450edef68
2025-07-07 11:49:48 +00:00
e3d014c009 *) scoreboard/mod_http2: record durations of HTTP/2 requests.
PR 69579 [Pierre Brochard <pierre.brochard.1982@m4x.org>]



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1923754 13f79535-47bb-0310-9956-ffa450edef68
2025-02-12 09:43:40 +00:00
1db5c2359a Add API exposing the DavBasePath setting for use by DAV repository
backend modules (mod_dav_svn needs this for POST method handling).

* modules/dav/main/mod_dav.c (dav_get_base_path): New function.

* include/ap_mmn.h: Bump MMN minor.

Github: closes #513


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1923639 13f79535-47bb-0310-9956-ffa450edef68
2025-02-07 11:09:25 +00:00
4915c21524 Add Multipath TCP (MPTCP) support (Proxy)
Multipath TCP (MPTCP), standardized in RFC8684 [1],
is a TCP extension that enables a TCP connection to
use different paths.

Multipath TCP has been used for several use cases.
On smartphones, MPTCP enables seamless handovers between
cellular and Wi-Fi networks while preserving established
connections. This use-case is what pushed Apple to use
MPTCP since 2013 in multiple applications [2]. On dual-stack
hosts, Multipath TCP enables the TCP connection to
automatically use the best performing path, either IPv4
or IPv6. If one path fails, MPTCP automatically uses
the other path.

To benefit from MPTCP, both the client and the server
have to support it. Multipath TCP is a backward-compatible
TCP extension that is enabled by default on recent
Linux distributions (Debian, Ubuntu, Redhat, ...). Multipath
TCP is included in the Linux kernel since version 5.6 [3].
To use it on Linux, an application must explicitly enable
it when creating the socket. No need to change anything
else in the application.

Adding the possibility to create MPTCP sockets would thus
be a really fine addition to httpd, by allowing clients
to make use of their different interfaces.

This patch introduces the possibilty to connect to backend
servers using MPTCP. Note however that these changes are
only available on Linux, as IPPROTO_MPTCP is Linux specific
for the time being.

For proxies, we can connect using MPTCP by passing the
\"multipathtcp\" parameter:

ProxyPass \"/example\" \"http://backend.example.com\" multipathtcp=On

We then store this information in the worker and create sockets
appropriately according to this value.

Link: https://www.rfc-editor.org/rfc/rfc8684.html [1]
Link: https://www.tessares.net/apples-mptcp-story-so-far/ [2]
Link: https://www.mptcp.dev [3]
Add Multipath TCP (MPTCP) support (Core)

Multipath TCP (MPTCP), standardized in RFC8684 [1],
is a TCP extension that enables a TCP connection to
use different paths.

Multipath TCP has been used for several use cases.
On smartphones, MPTCP enables seamless handovers between
cellular and Wi-Fi networks while preserving established
connections. This use-case is what pushed Apple to use
MPTCP since 2013 in multiple applications [2]. On dual-stack
hosts, Multipath TCP enables the TCP connection to
automatically use the best performing path, either IPv4
or IPv6. If one path fails, MPTCP automatically uses
the other path.

To benefit from MPTCP, both the client and the server
have to support it. Multipath TCP is a backward-compatible
TCP extension that is enabled by default on recent
Linux distributions (Debian, Ubuntu, Redhat, ...). Multipath
TCP is included in the Linux kernel since version 5.6 [3].
To use it on Linux, an application must explicitly enable
it when creating the socket. No need to change anything
else in the application.

Adding the possibility to create MPTCP sockets would thus
be a really fine addition to httpd, by allowing clients
to make use of their different interfaces.

This patch introduces the possibility to listen with MPTCP
sockets. Note however that these changes are only available
on Linux, as IPPROTO_MPTCP is Linux specific for the time being.

To do so, we extended the Listen directive to include
a \"multipathtcp\" option, allowing to create MPTCP sockets
instead of regular TCP ones:

Listen 80 options=multipathtcp

We then store this information in flags for the listen directive
and create sockets appropriately according to this value.

Link: https://www.rfc-editor.org/rfc/rfc8684.html [1]
Link: https://www.tessares.net/apples-mptcp-story-so-far/ [2]
Link: https://www.mptcp.dev [3]

Submitted by: Aperence <anthony.doeraene hotmail.com>
Github: closes #476


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1920586 13f79535-47bb-0310-9956-ffa450edef68
2024-09-12 07:59:22 +00:00
2f1f9c5df0 mod_proxy: Fix selection of ProxyPassMatch workers with host/port substitution. PR 69233.
With "ProxyPassMatch ^/([^/]+)/(.*)$ https://$1/$2", ap_proxy_get_worker_ex()
should not consider the length of scheme://host part of the given URL because
of the globbing match on the host part.

Fix it by setting worker->s>is_host_matchable when creating a worker with host
substitution and avoiding the min_match check in worker_matches() in this case.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919617 13f79535-47bb-0310-9956-ffa450edef68
2024-08-01 11:35:26 +00:00
f2db411286 factor out IS_SLASH, perdir fix
in per-dir, the filename will be internally redirected, so / is OK too.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918651 13f79535-47bb-0310-9956-ffa450edef68
2024-06-26 10:09:29 +00:00
6937b985ae mod_proxy: Fixup UDS filename for mod_proxy called through r->handler.
* modules/proxy/proxy_util.c:
  Export ap_proxy_fixup_uds_filename() from fix_uds_filename.
  Call it from ap_proxy_pre_request() even for rewritten balancer workers.

* modules/proxy/mod_proxy.h:
  Declare ap_proxy_fixup_uds_filename()

* modules/proxy/mod_proxy.c:
  Fixup UDS filename from r->handler in proxy_handler().

* include/ap_mmn.h:
  Bump MMN minor for ap_proxy_fixup_uds_filename()



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918626 13f79535-47bb-0310-9956-ffa450edef68
2024-06-25 23:49:09 +00:00
fe939ff386 MMN bump for recent additions
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918554 13f79535-47bb-0310-9956-ffa450edef68
2024-06-24 17:32:26 +00:00
67c65983d5 mpm_event,mod_http2,mod_status: Follow up to r1918257: CONN_STATE_ASYNC_WAITIO.
Per discussion on PR #449, have a separate state for returning the connection
to the MPM to wait for an IO (namely CONN_STATE_ASYNC_WAITIO), rather than
(ab)using CONN_STATE_PROCESSING.

This removes the need for AGAIN added in r1918257 (for now), and AP_MPMQ_CAN_AGAIN
is renamed to AP_MPMQ_CAN_WAITIO.

This is also the state that mod_status accounts for, so rename ->processing
to ->wait_io in process_score (shows as "wait-io" in mod_status and mod_lua).



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918482 13f79535-47bb-0310-9956-ffa450edef68
2024-06-21 09:48:12 +00:00
0d71da4bdf mpm_event,mod_http2: Keep compatibility with CONN_STATE_PROCESSING + OK
Before r1918022, returning OK with CONN_STATE_PROCESSING to mpm_event was
handled like/by CONN_STATE_LINGER "to not break old or third-party modules
which might return OK w/o touching the state and expect lingering close,
like with worker or prefork MPMs".

So we need a new return code to be allowed to apply the new POLLIN/POLLOUT
behaviour for CONN_STATE_PROCESSING, thus revive AGAIN as introduced by
Graham some times ago for a nonblocking WIP (moved to a branch/PR since then).

MPM event will advertise its ability to handle CONN_STATE_PROCESSING + AGAIN
with AP_MPMQ_CAN_AGAIN, and mod_http2 can use that to know how to return to
the MPM as expected. When !AP_MPMQ_CAN_AGAIN modules/mod_http2 can still use
CONN_STATE_WRITE_COMPLETION + CONN_SENSE_WANT_READ + c->clogging_input_filters
which will work in mpm_even-2.4.x still.

* include/ap_mmn.h:
  Bump MMN minor for AP_MPMQ_CAN_AGAIN and AGAIN.

* include/ap_mpm.h:
  Define AP_MPMQ_CAN_AGAIN.

* include/httpd.h:
  Define AGAIN.

* modules/http2/h2.h:
  No need for H2_USE_STATE_PROCESSING anymore with AP_MPMQ_CAN_AGAIN.

* modules/http2/h2_c1.c:
  For !keepalive case return to the MPM using CONN_STATE_PROCESSING + AGAIN
  or CONN_STATE_WRITE_COMPLETION + c->clogging_input_filters depending on
  AP_MPMQ_CAN_AGAIN only.

* modules/http2/h2_session.c:
  Can return to the MPM for h2_send_flow_blocked() provided it's async only.

* server/mpm/event/event.c:
  Rework process_socket()'s CONN_STATE_PROCESSING to handle AGAIN and preserve
  compatibility. Have a lingering_close label to goto there faster when
  process_lingering_close() is to be called. Improve relevant comments.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918257 13f79535-47bb-0310-9956-ffa450edef68
2024-06-11 14:46:29 +00:00
c09f4ffdbb Follow up to r1918098 (and r1918022): Actually bump the MMN.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918100 13f79535-47bb-0310-9956-ffa450edef68
2024-06-01 16:03:58 +00:00
d821182d76 mpm_event, mod_status: Separate processing and write completion queues.
As a follow up to r1918022 which handled the new CONN_STATE_PROCESS(ing) and
existing CONN_STATE_WRITE_COMPLETION in the same async queue, let's now have
two separates ones which allows more relevant async accounting in mod_status.

Rename CONN_STATE_PROCESS to CONN_STATE_PROCESSING as it's how it will be
called in mod_status.

* include/ap_mmn.h:
  MMN minor bump for process_score->processing counter.

* include/httpd.h:
  Rename CONN_STATE_PROCESS to CONN_STATE_PROCESSING.

* include/scoreboard.h:
  Add process_score->processing field.

* include/httpd.h, modules/http/http_core.c, modules/http2/h2_c1.c,
    server/mpm/event/event.c, server/mpm/motorz/motorz.c,
    server/mpm/simple/simple_io.c:
  Rename CONN_STATE_PROCESS to CONN_STATE_PROCESSING.

* server/mpm/event/event.c:
  Restore write_completion_q to handle connections in CONN_STATE_WRITE_COMPLETION.
  Use processing_q (renamed from process_q) solely for CONN_STATE_PROCESSING.
  Update process_score->processing according to the length of processing_q.
  
* modules/generators/mod_status.c:
  Show the value of process_score->processing in the stats.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918098 13f79535-47bb-0310-9956-ffa450edef68
2024-06-01 15:08:46 +00:00
0af4059050 Follow up to r1918022: MMN minor bump and checks for the new conn_state_e aliases' usability.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918035 13f79535-47bb-0310-9956-ffa450edef68
2024-05-29 09:41:25 +00:00
97a1873332 regex: Add AP_REG_NOTEMPTY_ATSTART maching option.
* include/ap_mmn.h:
  Bump MMN minor.

* include/ap_regex.h:
  Define AP_REG_NOTEMPTY_ATSTART bit.

* server/util_pcre.c(ap_regexec_ex):
  Map AP_REG_NOTEMPTY_ATSTART to native PCRE_NOTEMPTY_ATSTART.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915268 13f79535-47bb-0310-9956-ffa450edef68
2024-01-16 16:56:58 +00:00
e52a206008 regex: Add ap_regexec_ex() which can take a starting offset to match from.
* include/ap_mmn.h:
  Bump MMN minor.

* include/ap_regex.h:
  Declare ap_regexec_ex().

* server/util_pcre.c(ap_regexec, ap_regexec_len, ap_regexec_ex):
  Reuse existing ap_regexec_len() code to implement ap_regexec_ex() where the
  offset is given instead of zero, then implement ap_regexec{,len}() in terms
  of ap_regexec_ex().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915267 13f79535-47bb-0310-9956-ffa450edef68
2024-01-16 16:51:03 +00:00
29fb603784 mod_proxy: Add ap_proxy_worker_get_name() and deprecate ap_proxy_worker_name().
The latter requires a pool and returns a non constant string although it may
return worker shared data.

By computing the worker "UDS" name at init time we can return a constant name
in any case with no need for a pool, that's the new ap_proxy_worker_get_name().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1912461 13f79535-47bb-0310-9956-ffa450edef68
2023-09-21 13:31:15 +00:00
3c7f67fa2a mod_proxy: Handle backend address renewal with address_ttl= parameter.
Define a new proxy_address struct holding the current/latest sockaddr in use
by each proxy worker and conn. Since backend addresses can be updated when
their TTL expires and while connections are being processed, each address is
refcounted and freed only when the last worker (or conn) using it grabs the
new one.

The lifetime of the addresses is handled at a single place by the new
ap_proxy_determine_address() function. It guarantees to bind the current/latest
backend address to the passed in conn (or do nothing if it's up to date already).
The function is called indirectly by ap_proxy_determine_connection() for the
proxy modules that use it, or directly by mod_proxy_ftp and mod_proxy_hcheck.
It also is called eventually by ap_proxy_connect_backend() when connect()ing all
the current addresses fails, to check (PROXY_DETERMINE_ADDRESS_CHECK) if some
new addrs are available.

This commit is also a rework of the lifetime of conn->addr, conn->hostname
and conn->forward, using the conn->uds_pool and conn->fwd_pool for the cases
where the backend is connected through a UDS socket and a remote CONNECT proxy
respectively.

* include/ap_mmn.h:
  Minor bump for new function/fields.

* modules/proxy/mod_proxy.h (struct proxy_address,
                             ap_proxy_determine_addresss()):
  Declare ap_proxy_determine_addresss() and opaque struct proxy_address,
  new fields to structs proxy_conn_rec/proxy_worker_shared/proxy_worker.

* modules/proxy/mod_proxy.c (set_worker_param):
  Parse/set the new worker->address_ttl parameter.

* modules/proxy/proxy_util.c (proxy_util_register_hooks(),
                              ap_proxy_initialize_worker(),
                              ap_proxy_connection_reusable(),
                              ap_proxyerror(), proxyerror_core(),
                              init_conn_pool(), make_conn_subpool(),
                              connection_make(), connection_cleanup(),
                              connection_constructor()):
 Initialize *proxy_start_time in proxy_util_register_hooks() as the epoch
 from which expiration times are relative (i.e. seconds stored in an uint32_t
 for atomic changes).
 Make sure worker->s->is_address_reusable and worker->s->disablereuse are
 consistant in ap_proxy_initialize_worker(), thus no need to check for both
 in ap_proxy_connection_reusable().
 New proxyerror_core() helper taking an apr_status_t to log, wrap in
 ap_proxyerror().
 New make_conn_subpool() to create worker->cp->{pool,dns} with their own
 allocator.
 New connection_make() helper to factorize code in connection_cleanup() and
 connection_constructor().

* modules/proxy/proxy_util.c (proxy_address_inc(), proxy_address_dec(),
                              proxy_address_cleanup(), proxy_address_set_expired(),
                              worker_address_get(), worker_address_set(),
                              worker_address_resolve(), proxy_addrs_equal(),
                              ap_proxy_determine_address(),
                              ap_proxy_determine_connection(),
                              ap_proxy_connect_backend()):
 Implement ap_proxy_determine_address() using the above helpers for atomic changes,
 and call it from ap_proxy_determine_connection() and ap_proxy_connect_backend().

* modules/proxy/mod_proxy_ftp.c (proxy_ftp_handler):
  Use ap_proxy_determine_address() and use the returned backend->addr.

* modules/proxy/mod_proxy_hcheck.c (hc_determine_connection, hc_get_backend,
                                    hc_init_worker, hc_watchdog_callback):
  Use ap_proxy_determine_address() in hc_determine_connection() and call the
  latter from hc_get_backend(), replace hc_init_worker() by hc_init_baton()
  which now calls hc_get_hcworker() and hc_get_backend() to resolve the first
  address at init time.

* modules/proxy/mod_proxy_http.c (proxy_http_handler):
  Use backend->addr and ->hostname instead of worker->cp->addr and
  worker->s->hostname_ex respectively.

* modules/proxy/mod_proxy_ajp.c (ap_proxy_ajp_request):
  Use backend->addr and ->hostname instead of worker->cp->addr and
  worker->s->hostname_ex respectively.


Closes #367



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1912459 13f79535-47bb-0310-9956-ffa450edef68
2023-09-21 13:15:35 +00:00
3ed9d65b05 *) mod_http2: added support for bootstrapping WebSockets via HTTP/2, as
described in RFC 8441. A new directive 'H2WebSockets on|off' has been
     added. The feature is by default not enabled.
     As also discussed in the manual, this feature should work for setups
     using "ProxyPass backend-url upgrade=websocket" without further changes.
     Special server modules for WebSockets will have to be adapted,
     most likely, as the handling if IO events is different with HTTP/2.
     HTTP/2 WebSockets are supported on platforms with native pipes. This
     excludes Windows.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910507 13f79535-47bb-0310-9956-ffa450edef68
2023-06-20 12:01:09 +00:00
ed69ae3384 *) core: add final_resp_passed flag to request_rec to allow
ap_die() to judge if it can send out a response. Bump mmn.
     Enable test cases that check errors during response body to
     appear as error on client side.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910161 13f79535-47bb-0310-9956-ffa450edef68
2023-06-01 12:21:03 +00:00
3e638ff283 core: Add the token_checker hook, that allows authentication to take
place using mechanisms other than username/password, such as bearer
tokens.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909409 13f79535-47bb-0310-9956-ffa450edef68
2023-04-25 17:35:08 +00:00
1925882d55 core: Be explicit if an enclosing directive contains a path or a
regex.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909135 13f79535-47bb-0310-9956-ffa450edef68
2023-04-14 14:02:11 +00:00
63d0e49490 Follow up to r1908380: MMN minor bump for AP_CTIME_OPTION_GMTOFF.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908557 13f79535-47bb-0310-9956-ffa450edef68
2023-03-20 10:48:07 +00:00
2fa15c2c06 Do not double encode encoded slashes
In case that AllowEncodedSlashes is set to NoDecode do not double encode
encoded slashes in the URL sent by the reverse proxy to the backend.

* include/ap_mmn.h: Document the addition of ap_proxy_canonenc_ex to the API.

* modules/proxy/mod_proxy.h: Declare ap_proxy_canonenc_ex and define flag
      values.

* modules/proxy/proxy_util.c: Implement ap_proxy_canonenc_ex by modifying
      ap_proxy_canonenc accordingly and reimplement ap_proxy_canonenc to
      use ap_proxy_canonenc_ex with the appropriate flag.

* modules/http2/mod_proxy_http2.c, modules/proxy/mod_proxy_*.c: Set the
      correct flag based on the AllowEncodedSlashes configuration and use
      ap_proxy_canonenc_ex instead of ap_proxy_canonenc.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908341 13f79535-47bb-0310-9956-ffa450edef68
2023-03-13 10:24:30 +00:00
1aa9416a40 bundle in r1904518
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906495 13f79535-47bb-0310-9956-ffa450edef68
2023-01-09 13:19:41 +00:00
1f44d315c9 bump again
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1905669 13f79535-47bb-0310-9956-ffa450edef68
2022-12-01 13:07:45 +00:00
44fd8339ef Bump mmn
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1905646 13f79535-47bb-0310-9956-ffa450edef68
2022-11-30 14:44:05 +00:00
9d74016b80 *) core: add ap_sb_get_child_thread() to retrieve child_num
and thread_num from a scoreboard handle.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900029 13f79535-47bb-0310-9956-ffa450edef68
2022-04-19 10:16:02 +00:00
fbb84e00fa Merge PR 311:
*) core/mod_http: use REQUEST meta buckets and a new HTTP/1.x specific
     input filter to separate the handling for HTTP requests from the
     handling of HTTP/1.x request parsing and checks.
     A new HTTP1_REQUEST_IN filter installs itself on http/1.1 connections
     before a request is being read. It generates either a REQUEST meta
     bucket on success or an ERROR bucket with the proposed response status.
     The core connection processing, relying on ap_read_request(), now expects
     a REQUEST or ERROR bucket from the input filters and is agnostic to
     specific HTTP versions and how they bring requests into the server.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899799 13f79535-47bb-0310-9956-ffa450edef68
2022-04-13 07:40:17 +00:00
cc232ba454 *) core: add ap_h1_append_header() for single header values.
*) mod_proxy: use of new ap_h1_header(s) functions for
     formatting HTTP/1.1 requests.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899550 13f79535-47bb-0310-9956-ffa450edef68
2022-04-04 09:41:25 +00:00
4442201e61 *) core/mod_http/mod_http2:
- adds new meta bucket types REQUEST, RESPONSE and HEADERS to the API.
     - adds a new method for setting standard response headers Date and Server
     - adds helper methods for formatting parts of HTTP/1.x, like headers and 
       end chunks for use in non-core parts of the server, e.g. mod_proxy
     - splits the HTTP_IN filter into a "generic HTTP" and "specific HTTP/1.x" 
       filter. The latter one named HTTP1_BODY_IN.
     - Uses HTTP1_BODY_IN only for requests with HTTP version <= 1.1
     - Removes the chunked input simulation from mod_http2
     - adds body_indeterminate flag to request_rec that indicates that a request 
       body may be present and needs to be read/discarded. This replaces logic 
       that thinks without Content-Length and Transfer-Encoding, no request 
       body can exist.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899547 13f79535-47bb-0310-9956-ffa450edef68
2022-04-04 08:24:09 +00:00
6bd9d17e08 *) core: adding a new hook and method to the API:
create_secondary_connection and ap_create_secondary_connection()
     to setup connections related to a "master" one, as used in
     the HTTP/2 protocol implementation.

  *) mod_http2: using the new API calls to get rid of knowledge
     about how the core handles conn_rec specifics.
     Improvements in pollset stream handling to use less sets.
     Using atomic read/writes instead of volatiles now.
     Keeping a reserve of "transit" pools and bucket_allocs for
     use on secondary connections to avoid repeated setup/teardowns.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899032 13f79535-47bb-0310-9956-ffa450edef68
2022-03-18 09:52:52 +00:00
2e239ed8e6 * core/mpm: add hook 'child_stopped` that gets called when the MPM has
stopped all processing in a child process. This is when all running
    threads shall be stopped and joined.
    [Stefan Eissing]



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1898369 13f79535-47bb-0310-9956-ffa450edef68
2022-02-24 11:53:53 +00:00
b11e669f07 *) core/mod_ssl/mpm_event: reverting changes to nonblocing SSL handshakes
to stabilize CI tests again. Previous revision of trunk has been copied
     to branches/trunk-ssl-handshake-unblocking to make those into a PR where
     changes can be discussed and tested separately.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897760 13f79535-47bb-0310-9956-ffa450edef68
2022-02-04 12:22:26 +00:00
3e0035d189 core: Follow up to r1897460: Provide ap_thread_main_create().
Replace ap_thread_current_create() by ap_thread_main_create() which is how
it's used by httpd. The former is now a local helper only to implement the
latter.

This allows to consolidate/factorize common code in the main() of httpd and
the unix MPMs.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897543 13f79535-47bb-0310-9956-ffa450edef68
2022-01-27 12:34:53 +00:00
6044859057 core: Efficient ap_thread_current() when apr_thread_local() is missing.
#define ap_thread_create, ap_thread_current_create and ap_thread_current to
their apr-1.8+ equivalent if available, or implement them using the compiler's
thread_local mechanism if available, or finally provide stubs otherwise.

#define AP_HAS_THREAD_LOCAL to 1 in the two former case or 0 otherwise, while
AP_THREAD_LOCAL is defined to the compiler's keyword iff AP_HAS_THREAD_LOCAL.

Replace all apr_thread_create() calls with ap_thread_create() so that httpd
threads can use ap_thread_current()'s pool data as Thread Local Storage.

Bump MMN minor.

* include/httpd.h():
  Define AP_HAS_THREAD_LOCAL, AP_THREAD_LOCAL (eventually), ap_thread_create(),
  ap_thread_current_create() and ap_thread_current().
  
* server/util.c:
  Implement ap_thread_create(), ap_thread_current_create() and
  ap_thread_current() when APR < 1.8.

* modules/core/mod_watchdog.c, modules/http2/h2_workers.c,
    modules/ssl/mod_ssl_ct.c:
  Use ap_thread_create() instead of apr_thread_create.

* server/main.c:
  Use AP_HAS_THREAD_LOCAL and ap_thread_current_create instead of APR's.

* server/util_pcre.c:
  Use AP_HAS_THREAD_LOCAL and ap_thread_current instead of APR's.

* server/mpm/event/event.c, server/mpm/worker/worker.c,
    server/mpm/prefork/prefork.c:
  Use ap_thread_create() instead of apr_thread_create.
  Create an apr_thread_t/ap_thread_current() for the main chaild thread usable
  at child_init().
  
* server/mpm/winnt/child.c:
  Use ap_thread_create() instead of CreateThread().
  Create an apr_thread_t/ap_thread_current() for the main chaild thread usable



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897460 13f79535-47bb-0310-9956-ffa450edef68
2022-01-25 17:34:57 +00:00
3c6a707491 event: Add AP_MPM_CAN_AGAIN and AGAIN to signal to the MPM that
non blocking behaviour is requested.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897423 13f79535-47bb-0310-9956-ffa450edef68
2022-01-24 16:14:42 +00:00
54a200291b event: Add support for non blocking behaviour in the
CONN_STATE_READ_REQUEST_LINE phase, in addition to the existing
CONN_STATE_WRITE_COMPLETION phase. Update mod_ssl to perform non blocking
TLS handshakes.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897281 13f79535-47bb-0310-9956-ffa450edef68
2022-01-21 00:09:24 +00:00
85051bd9ac mod_proxy: Bump max worker name to 384 chars.
The worker name is a fully qualified URI while the hostname's limit is 256
already, so potentially more than 256 are needed to store the name. Let's
use 384.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1896253 13f79535-47bb-0310-9956-ffa450edef68
2021-12-21 18:42:30 +00:00
3ec0ffb9e1 http: Enforce that fully qualified uri-paths not to be forward-proxied
have an http(s) scheme, and that the ones to be forward proxied have a
      hostname, per HTTP specifications.

The early checks avoid failing the request later on and thus save cycles
for those invalid cases.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1895921 13f79535-47bb-0310-9956-ffa450edef68
2021-12-13 18:55:18 +00:00
499f5d137c Fix ap_mmn.h after r1893971.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893981 13f79535-47bb-0310-9956-ffa450edef68
2021-10-07 12:35:33 +00:00
48b5dfd696 core: Add ap_unescape_url_ex() for better decoding control, and deprecate
unused AP_NORMALIZE_DROP_PARAMETERS flag.
 


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893971 13f79535-47bb-0310-9956-ffa450edef68
2021-10-07 12:00:20 +00:00
cdd13288b8 Add dav_get_liveprop_element() to hide the implementation by which
the element is passed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893643 13f79535-47bb-0310-9956-ffa450edef68
2021-09-26 12:27:59 +00:00
b44b9b6b2a mod_proxy: Handle ap_proxy_buckets_lifetime_transform() errors.
* modules/proxy/mod_proxy.h,modules/proxy/proxy_util.c:
  Add ap_proxy_fill_error_brigade() to factorize proxy error handling
  on the client connection side.

* modules/proxy/mod_proxy_{http,ajp,uwsgi}.c:
  Use ap_proxy_fill_error_brigade() where needed, including when an
  empty brigade is returned on the backend side or when calling
  ap_proxy_buckets_lifetime_transform fails.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893595 13f79535-47bb-0310-9956-ffa450edef68
2021-09-24 11:25:42 +00:00
074d55133a mod_proxy: Restore ap_proxy_transfer_between_connections().
* modules/proxy/mod_proxy.h:
  Restore the interface of ap_proxy_transfer_between_connections() back to
  before MMN 20210506.0.
  Add ap_proxy_tunnel_conn_bytes_in() and ap_proxy_tunnel_conn_bytes_out().
  New proxy_tunnel_conn_t typedef'ed from opaque struct proxy_tunnel_conn.

* modules/proxy/mod_proxy.h(ap_proxy_tunnel_conn_get_read,
                            ap_proxy_tunnel_conn_get_transferred):
  Axed/replaced by ap_proxy_tunnel_conn_bytes_in() and
  ap_proxy_tunnel_conn_bytes_out().

* modules/proxy/proxy_util.c(struct proxy_tunnel_conn):
  Replace "exchanged" by "bytes_in" and "bytes_out".

* modules/proxy/proxy_util.c(proxy_transfer):
  New helper implementing ap_proxy_transfer_between_connections() and
  returning both &bytes_in and &bytes_out.

* modules/proxy/proxy_util.c(ap_proxy_transfer_between_connections):
  Now calls proxy_transfer().

* modules/proxy/proxy_util.c(ap_proxy_tunnel_conn_bytes_in,
                             ap_proxy_tunnel_conn_bytes_out):
  Return tc->bytes_in and tc->bytes_out respectively.

* modules/proxy/proxy_util.c(proxy_tunnel_forward):
  Use proxy_transfer() which updates in->bytes_in, &out->bytes_out.
  tunnel->replied will be updated in proxy_tunnel_run().

* modules/proxy/proxy_util.c(proxy_tunnel_forward):
  Fall through the "done" label in any case to set tunnel->replied based
  on tunnel->client->bytes_out > 0.

* modules/proxy/mod_proxy_http.c(ap_proxy_http_process_response):
  Use ap_proxy_tunnel_conn_bytes_{in,out}() for worker->s->{read,transferred}
  accounting.

* modules/proxy/mod_proxy_http.c(proxy_http_async_finish):
  Update worker->s->{read,transferred} when async too.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893594 13f79535-47bb-0310-9956-ffa450edef68
2021-09-24 10:27:16 +00:00
63da5b997f mod_proxy: typedef struct proxy_tunnel_conn proxy_tunnel_conn_t.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893593 13f79535-47bb-0310-9956-ffa450edef68
2021-09-24 10:09:23 +00:00
6d9a8cd1f2 In case one of the pre_connection hooks causes the hook run to stop by an error
the pre_connection hook of the core module maybe did not run
(it is APR_HOOK_REALLY_LAST) and hence we missed to

- Put the socket in c->conn_config
- Setup core output and input filters
- Set socket options and timeouts

For calls of ap_run_pre_connection where this matters create a wrapper named
ap_pre_connection that ensures that this happens.

* include/ap_mmn.h: Bump minor version as we added new ap_pre_connection
  function.

* include/http_connection.h: Declare ap_pre_connection prototype.

* server/connection.c: Make use of ap_pre_connection in ap_process_connection.

* server/core.c: Implement ap_pre_connection.

* server/mpm/event/event.c: Make use of ap_pre_connection.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893497 13f79535-47bb-0310-9956-ffa450edef68
2021-09-21 20:03:52 +00:00
2b7f51ade7 core: Add ap_create_connection() to create a server or client/proxy connection.
c->outgoing shouldn't be set by mod_ssl, ap_create_connection() allows that
and this commit also replaces all the calls to ap_run_create_connection() in
mod_proxy modules (not in the MPMs which create incoming connections only).

* include/http_connection.h, server/connection.c:
  Declare and implement ap_create_connection().

* modules/proxy/proxy_util.c, modules/proxy/mod_proxy_connect.c,
  modules/proxy/mod_proxy_ftp.c:
  Use ap_create_connection() instead of ap_run_create_connection(), and don't
  provide a connection_id a scoreboard handle for outgoing connection.

* server/log.c(do_errorlog_default):
  Use c->outgoing instead of c->sbh to determine if it's a "client" or "remote"
  connection.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1893184 13f79535-47bb-0310-9956-ffa450edef68
2021-09-09 16:55:24 +00:00
324ae13e8e core: follow up to r1891148: WC bucket defaulting to FLUSH bucket.
Define WC bucket semantics as:
/**
 * @brief Write Completion (WC) bucket
 *
 * A WC bucket is a FLUSH bucket with special ->data == &ap_bucket_wc_data,
 * still both AP_BUCKET_IS_WC() and APR_BUCKET_IS_FLUSH() hold for them so
 * they have the same semantics for most filters, namely:
 *   Everything produced before shall be passed to the next filter, including
 *   the WC/FLUSH bucket itself.
 * The distinction between WC and FLUSH buckets is only for filters that care
 * about write completion (calling ap_filter_reinstate_brigade() with non-NULL
 * flush_upto), those can setaside WC buckets and the preceding data provided
 * they have first determined that the next filter(s) have pending data
 * already, usually by calling ap_filter_should_yield(f->next).
 */

The only filters that care about write completion for now are
ap_core_output_filter() and ssl_io_filter_output(), which try to fill
in the pipe as much as possible, using ap_filter_reinstate_brigade(&flush_upto)
to determine whether they should flush (blocking) or setaside their remaining
data.

So ap_filter_reinstate_brigade() is made to not treat WC as FLUSH buckets and
keep the above filters working as before (and correctly w.r.t. above WC bucket
semantics).

* include/ap_mmn.h, include/util_filter.h:
  Axe specific ap_bucket_type_wc and define global &ap_bucket_wc_data address to
  mark WC buckets checked by AP_BUCKET_IS_WC().

* server/util_filter.c (ap_filter_reinstate_brigade):
  Don't treat WC buckets as FLUSH buckets.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1892468 13f79535-47bb-0310-9956-ffa450edef68
2021-08-20 09:36:19 +00:00
f11b97a291 Corrected MODULE_MAGIC_NUMBER_MINOR.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1891924 13f79535-47bb-0310-9956-ffa450edef68
2021-07-31 14:28:58 +00:00
19360d53df * core/mpm: add hook 'child_stopping` that gets called when the MPM is
stopping a child process. The additional `graceful` parameter allows
    registered hooks to free resources early during a graceful shutdown.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1891919 13f79535-47bb-0310-9956-ffa450edef68
2021-07-31 13:36:19 +00:00