1
0
mirror of https://github.com/apache/httpd.git synced 2026-10-23 22:49:01 +03:00

244 Commits

Author SHA1 Message Date
Eric Covener
ef98f4f494 backport 1927038 from trunk
improve h2 header error handling

Rewviewed By: icing, covener, rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1927046 13f79535-47bb-0310-9956-ffa450edef68
2025-07-07 12:12:49 +00:00
Eric Covener
8830432184 backport 1927036 from trunk
tolerate missing host header in h2 proxy

Reviewed By: jorton, icing, rpluem



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1927044 13f79535-47bb-0310-9956-ffa450edef68
2025-07-07 12:05:49 +00:00
Stefan Eissing
d4a61302bc Merge of /httpd/httpd/trunk:r1925975
*) mod_http2: update to version 2.0.32
     The code setting the connection window size was set wrong,
     preventing `H2WindowSize` to work.
     Fixed <https://github.com/icing/mod_h2/issues/300>.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926082 13f79535-47bb-0310-9956-ffa450edef68
2025-06-03 08:07:31 +00:00
Stefan Eissing
1caed4ed9f Merge /httpd/httpd/trunk:r1923754
*) 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/branches/2.4.x@1926080 13f79535-47bb-0310-9956-ffa450edef68
2025-06-03 08:02:35 +00:00
Stefan Eissing
355fd0f176 Merge /httpd/httpd/trunk:r1924554
* mod_proxy_http2: revert r1912193 for detecting broken backend connections
    as this interferes with backend selection who a node is unresponsive.
    PR69624.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926078 13f79535-47bb-0310-9956-ffa450edef68
2025-06-03 07:48:08 +00:00
Stefan Eissing
0343adfaed Merge of /httpd/httpd/trunk:r1924145,1924164,1924197
*) mod_http2: update to version 2.0.30
     - Fixed bug in handling over long response headers. When the 64 KB limit
       of nghttp2 was exceeded, the request was not reset and the client was
       left hanging, waiting for it. Now the stream is reset.
     - Added new directive `H2MaxHeaderBlockLen` to set the limit on response
       header sizes.
     - Fixed handling of Timeout vs. KeepAliveTimeout when first request on a
       connection was reset.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926076 13f79535-47bb-0310-9956-ffa450edef68
2025-06-03 07:40:48 +00:00
Rainer Jung
0acf2161c6 *) mod_http2: fix test_h2_200_17+18 for newer curl versions. Just add log
output and add to test checks. No functional change.

Merges r1923187 from trunk.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1923238 13f79535-47bb-0310-9956-ffa450edef68
2025-01-19 19:32:14 +00:00
Jim Jagielski
fcd23efdc0 *) mod_http2: Fix failed request counting and keepalive timeout
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1922960 13f79535-47bb-0310-9956-ffa450edef68
2025-01-07 15:06:41 +00:00
Jim Jagielski
83ab7e7e1c *) Easy patches: synch 2.4.x and trunk
- server: Use apr_size_t instead of int to harden against overflows
         - mod_http2: DOXYGEN has nothing to do here, just remove this
                      strange "#if defined(DOXYGEN)"
         - test: make the compiler happy when using --enable-maintainer-mode
         - mod_proxy: Fix format string type check
         - mod_http2: Fix comment, no functional change
         - <various>: Remove unnecessary APLOGNO() use in TRACE-level logging
         - mod_cache_socache: Update comment only, to remove reference to
                              session cache
         - mod_dav: Fix error message formatting if an unauthenticated user
                    tries to use an authenticated user's lock token
         - <none>: trigger ci
         - server: Fix typo in comment



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1922956 13f79535-47bb-0310-9956-ffa450edef68
2025-01-07 15:00:40 +00:00
Yann Ylavic
8ace8c7fc9 Merge r1918003, r1918022, r1918035, r1918078, r1918098, r1918099, r1918257, r1918482, r1918483, r1918491, r1919141, r1919148 from trunk
*) mod_http2: sync with module's github.
    - on newer HTTPD versions, return connection monitoring
      to the event MPM when block on client updates.
      2.4.x versions still treat connections in the event
      MPM as KeepAlive and purge them on load in the middle
      of response processing.
    - spelling fixes
    - support for yield calls in c2 "network" filter


 mpm_event,core: Handle async POLLIN/POLLOUT in CONN_STATE_PROCESS state.

* include/httpd.h:
  Rename CONN_STATE_CHECK_REQUEST_LINE_READABLE to CONN_STATE_KEEPALIVE
  and CONN_STATE_READ_REQUEST_LINE to CONN_STATE_PROCESS, keeping the
  old enums as aliases. Rework comments about each state.

* server/mpm/event/event.c:
  Use the new states names.
  Let the process_connection hooks return CONN_STATE_PROCESS for mpm_event
  to POLLIN or POLLOUT depending on c->cs->sense being CONN_SENSE_WANT_READ
  or CONN_SENSE_WANT_WRITE respectively.
  Remove (ab)use of CONN_STATE_WRITE_COMPLETION with CONN_SENSE_WANT_READ to
  mean poll() for read (and the need for the obscure c->clogging_input_filters
  to make it work as expected). This is what CONN_STATE_PROCESS is for now.
  Update the comment about the states that can be returned by process_connection
  hooks (and their usage).
  Use the same queue (process_q renamed from write_completion_q) for polling
  connections in both CONN_STATE_PROCESS and CONN_STATE_WRITE_COMPLETION
  states since they both use the same (server_rec's) Timeout. This implies
  that both states are accounted as "write-completion" in mod_status for now.

* server/mpm/motorz/motorz.c, server/mpm/simple/simple_io.c, modules/http/http_core.c:
  Use the new states names (only).

* include/scoreboard.h:
  Change comment about process_score->write_completion to note that the
  counter refers to CONN_STATE_PROCESS connections returned to the MPM
  too.

* modules/http2/h2_c1.c:
  Return the c1 connection with the CONN_STATE_PROCESS state rather than
  CONN_STATE_WRITE_COMPLETION when waiting for a window update (i.e. ask
  the MPM to poll for read directly). This avoids the transition to
  CONN_STATE_KEEPALIVE which could kill the connection under high load.


Github: closes #448


Follow up to r1918022: MMN minor bump and checks for the new conn_state_e aliases' usability.

mpm_event: Don't spam with "Stopping process due to MaxConnectionsPerChild"

When MaxConnectionsPerChild is reached there may be some connections to process
still and the listener should stop writing this at every loop. Logging once
is enough.

* server/mpm/event/event.c(check_infinite_requests): Raise conns_this_child
  unconditionally.
  

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.


Follow up to r1918098 (and r1918022): Push missing changes.

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.


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).


mpm_event: Follow up to r1918482: CONN_STATE_ASYNC_WAITIO > CONN_STATE_LINGER.


mpm_event: Follow up to r1918482: CONN_STATE_LINGER* are not the last anymore.

Since CONN_STATE_ASYNC_WAITIO, we cannot check for < or >= CONN_STATE_LINGER
anymore to determine if in an lingering close state, so let's add a new
CONN_STATE_IS_LINGERING_CLOSE() macro for this and use it in mpm_event.

The test for state == CONN_STATE_LINGER in process_lingering_close() is a
bit weak too in order to call ap_start_lingering_close() the first time only,
so have a conn_state->linger_started flag instead.


mod_status: Follow up to r1918482: Bump colspan for the new wait-io colomn


mod_status: "Threads" span three colomns (busy, graceful, idle), not two.


Submitted by: icing, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic
Reviewed by: ylavic, icing, gbechis
Github: closes #449


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1919548 13f79535-47bb-0310-9956-ffa450edef68
2024-07-27 14:18:49 +00:00
Yann Ylavic
4d3a308014 mod_proxy_http2: ap_proxy_determine_connection()'s given &url is in/out.
* modules/http2/mod_proxy_http2.c(proxy_http2_handler):
  Restart from the original URL on reconnect.

Merges r1918627 from trunk (experimental/CTR).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1918628 13f79535-47bb-0310-9956-ffa450edef68
2024-06-26 00:28:32 +00:00
Eric Covener
62aa64e5ae Merge r1918548 from trunk:
mod_http2: early exit if bb is null



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1918557 13f79535-47bb-0310-9956-ffa450edef68
2024-06-24 17:51:42 +00:00
Eric Covener
0d73970ec1 Merge r1916771 from trunk:
bail after too many failed reads

Submitted By: icing




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1916779 13f79535-47bb-0310-9956-ffa450edef68
2024-04-03 12:12:55 +00:00
Joe Orton
f7f0f9bf11 Merge r1915281 from trunk:
*) mod_http2: v2.0.26 with the following fixes:
     - Fixed `Date` header on requests upgraded from HTTP/1.1 (h2c). Fixes
       <https://github.com/icing/mod_h2/issues/272>.
     - Fixed small memory leak in h2 header bucket free. Thanks to
       Michael Kaufmann for finding this and providing the fix.

Submitted by: icing
Reviewed by: icing, gbechis, jorton


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1916413 13f79535-47bb-0310-9956-ffa450edef68
2024-03-19 08:38:00 +00:00
Ruediger Pluem
3917af2aed * Fully backport r1913019 and leave it to r1913023 to include it conditionally.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913027 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 13:39:41 +00:00
Stefan Eissing
86fde0f8fd Merge of /httpd/httpd/trunk:r1913023
* modules/http2: Make WebSockets support conditional also
 on APR 1.7.x since apr_encode.h is required. Restore
 #include "apr_encode.h" removed in previous commit.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913024 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 13:21:37 +00:00
Stefan Eissing
c90c542986 * modules/http2/h2_session.c (h2_session_start):
Restrict WebSockets options handling to with-WS builds.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913020 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 12:43:44 +00:00
Joe Orton
3c6caeb2dc Merge r1913007 from trunk: [RTC exception for APLOGNO]
* modules/http2: Fill in APLOGNO.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913014 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 11:49:09 +00:00
Stefan Eissing
b763f5f4e8 Merge of /httpd/httpd/trunk:r1913005
*) mod_http2: enable WebSockets only when compiling against a
     recent enought nghttp2 version.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913006 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 11:11:45 +00:00
Stefan Eissing
decce82a70 Merge of /httpd/httpd/trunk:r1912999
* mod_http2: improved early cleanup of streams.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1913000 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 09:05:00 +00:00
Stefan Eissing
582c533c17 Merge of 1912385 from trunk:
*) mod_http2: fixed a bug in handling of stream timeouts.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1912991 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 06:18:54 +00:00
Stefan Eissing
952cc27cad Merge of 1912415 from trunk:
mod_http2: fixed a compile time issue on Windows builds.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1912989 13f79535-47bb-0310-9956-ffa450edef68
2023-10-16 06:11:19 +00:00
Stefan Eissing
d7f0c6d189 Merge of /httpd/httpd/trunk:r1912180
*) mod_proxy_http2: fix `X-Forward-Host` header to carry the correct value.
     Fixes PR66752.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1912194 13f79535-47bb-0310-9956-ffa450edef68
2023-09-08 13:23:00 +00:00
Stefan Eissing
c18c18161b Merge of /httpd/httpd/trunk:r1911964
*) mod_proxy_http2: improved error handling on connection errors while
     response is already underway.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1912193 13f79535-47bb-0310-9956-ffa450edef68
2023-09-08 13:18:58 +00:00
Stefan Eissing
64c420f52a mod_http2: update version that has become v2.0.22 in github release
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1911981 13f79535-47bb-0310-9956-ffa450edef68
2023-08-29 07:46:03 +00:00
Stefan Eissing
0d1d79b020 Merge from trunk:
*) 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.
     New directive `H2ProxyRequests on|off` to enable handling
     of HTTP/2 requests in a forward proxy configuration.
     General forward proxying is enabled via `ProxyRequests`. If the
     HTTP/2 protocol is also enabled for such a server/host, this new
     directive is needed in addition.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1911979 13f79535-47bb-0310-9956-ffa450edef68
2023-08-29 07:23:10 +00:00
Stefan Eissing
c973637478 Merge r1911291 from trunk:
*) mod_http2: Fix reporting of `Total Accesses` in server-status to not count
     HTTP/2 requests twice. Fixes PR 66801.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1911858 13f79535-47bb-0310-9956-ffa450edef68
2023-08-23 07:52:33 +00:00
Joe Orton
ff558f52f5 Merge r1908502 from trunk:
mod_http2: Fix memory leak in calc_sha256_hash().
Submitted by: ylavic
Reviewed by: icing, jorton, covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1910854 13f79535-47bb-0310-9956-ffa450edef68
2023-07-07 12:04:17 +00:00
Stefan Eissing
06ceb22deb backport of https://github.com/apache/httpd/pull/364
Merge 1907696,1907697 from trunk:

  *) mod_http2: new directive 'H2MaxDataFrameLen n' to limit the maximum
     amount of response body bytes put into a single HTTP/2 DATA frame.
     Setting this to 0 places no limit (but the max size allowed by the
     protocol is observed).
     The module, by default, tries to use the maximum size possible, which is
     somewhat around 16KB. This sets the maximum. When less response data is
     available, smaller frames will be sent.

Merge r1909769 from trunk (plus sync mod_http2.xml)

  *) mod_http2: v2.0.15 with the following fixes and improvements
     - New directive 'H2EarlyHint name value' to add headers to a response,
       picked up already when a "103 Early Hints" response is sent. 'name' and
       'value' must comply to the HTTP field restrictions.
       This directive can be repeated several times and header fields of the
       same names add. Sending a 'Link' header with 'preload' relation will
       also cause a HTTP/2 PUSH if enabled and supported by the client.
     - Fixed an issue where requests were not logged and accounted in a timely
       fashion when the connection returns to "keepalive" handling, e.g. when
       the request served was the last outstanding one.
       This led to late appearance in access logs with wrong duration times
       reported.
     - Accurately report the bytes sent for a request in the '%O' Log format.
       This addresses #203, a long outstanding issue where mod_h2 has reported
       numbers over-eagerly from internal buffering and not what has actually
       been placed on the connection.
       The numbers are now the same with and without H2CopyFiles enabled.

Merge r1910157 from trunk

 * mod_proxy_http2: fixed using the wrong "bucket_alloc" from the backend
   connection when sending data on the frontend one. This caused crashes
   or infinite loops in rare situations.
 * mod_proxy_http2: fixed a bug in retry/response handling that could lead
   to wrong status codes or HTTP messages send at the end of response bodies
   exceeding the announced content-length.
 * mod_proxy_http2: fix retry handling to not leak temporary errors.
   On detecting that that an existing connection was shutdown by the other
   side, a 503 response leaked even though the request was retried on a
   fresh connection.
 * mod_http2: fixed a bug that did cleanup of consumed and pending buckets in
   the wrong order when a bucket_beam was destroyed.

Merge of 1910331,1910386,1910441 from trunk

  *) mod_http2: fixed a bug in flushing pending data on an already closed
     connection that could lead to a busy loop, preventing the HTTP/2 session
     to close down successfully. Fixed PR 66624.
     Fixed a bug that could lead to a crash in main connection
     output handling. This occured only when the last request on a HTTP/2
     connection had been processed and the session decided to shut down.
     This could lead to an attempt to send a final GOAWAY while the previous
     write was still in progress. See PR 66646.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1910699 13f79535-47bb-0310-9956-ffa450edef68
2023-06-30 07:22:40 +00:00
Stefan Eissing
7dd0de2c6d Merge of 1909932,1909982 from trunk
*) mod_http2: avoid double chunked-encoding on internal redirects.
     PR 66597 [Yann Ylavic, Stefan Eissing]



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1910501 13f79535-47bb-0310-9956-ffa450edef68
2023-06-20 10:47:27 +00:00
Stefan Eissing
bf1556ed1b Merge r1909989 from trunk:
*) mod_proxy_http2: fix retry handling to not leak temporary errors.
     On detecting that that an existing connection was shutdown by the other
     side, a 503 response leaked even though the request was retried on a
     fresh connection.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1909992 13f79535-47bb-0310-9956-ffa450edef68
2023-05-22 14:18:14 +00:00
Ruediger Pluem
fd92481223 Merge r1908827, r1908838 from trunk:
mod_proxy: Check for space/ctrls in nocanon path/urls before forwarding.



Follow up to r1908827: CHANGES entry.
Submitted by: ylavic
Reviewed by: ylavic, rpluem, covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908865 13f79535-47bb-0310-9956-ffa450edef68
2023-03-31 14:37:07 +00:00
Ruediger Pluem
9b8cf1746b Merge r1908341, r1908628, r1908629 from trunk:
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.


* Whitespace fixes. No functional change.

* Fix typo

Reviewed by: rpluem, ylavic, covener

Github: closes #351


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908864 13f79535-47bb-0310-9956-ffa450edef68
2023-03-31 14:33:00 +00:00
Stefan Eissing
cd2312bdb6 Merge r1908691 from trunk:
*) mod_http2: fixed a crash during connection termination. See PR 66539.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908852 13f79535-47bb-0310-9956-ffa450edef68
2023-03-31 12:04:33 +00:00
Eric Covener
a356fdbfb9 Merge r1908302 from trunk:
move B=xx example to the bottom

show example with quoted flags and a space


Reviewed By: ylavic, rpluem, covener


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908536 13f79535-47bb-0310-9956-ffa450edef68
2023-03-19 21:29:58 +00:00
Ruediger Pluem
8b93a6512f Merge r1908116 from trunk:
* modules/http2/mod_proxy_http2.c: Fix missing APLOGNO.

Submitted by: jorton
Reviewed by: rpluem

Note: mod_proxy_http2 is CTR on 2.4.x.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908118 13f79535-47bb-0310-9956-ffa450edef68
2023-03-06 10:00:09 +00:00
Eric Covener
8789f6bb92 Merge r1908095 from trunk:
don't forward invalid query strings

    Submitted by: rpluem

Reviewed By:  covener, fielding, rpluem, gbechis



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908096 13f79535-47bb-0310-9956-ffa450edef68
2023-03-05 20:28:43 +00:00
Stefan Eissing
3562db01e3 Merge of r1906775 from trunk:
*) mod_http2: client resets of HTTP/2 streams led to unwanted 500 errors
     reported in access logs and error documents. The processing of the
     reset was correct, only unneccesary reporting was caused.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1906806 13f79535-47bb-0310-9956-ffa450edef68
2023-01-19 16:01:46 +00:00
Stefan Eissing
51484e5d8f Merge of httpd/httpd/trunk:r1906051
*) mod_proxy_http2: apply the standard httpd content type handling
     to responses from the backend, as other proxy modules do. Fixes PR 66391.
     Thanks to Jérôme Billiras for providing the patch.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1906476 13f79535-47bb-0310-9956-ffa450edef68
2023-01-09 07:47:29 +00:00
Stefan Eissing
9767274b88 *) mod_http2: version 2.0.10 of the module, synchronizing changes
with the gitgub version. This is a partial rewrite of how connections
     and streams are handled.
     - an APR pollset and pipes (where supported) are used to monitor
       the main connection and react to IO for request/response handling.
       This replaces the stuttered timed waits of earlier versions.
     - H2SerializeHeaders directive still exists, but has no longer an effect.
     - Clients that seemingly misbehave still get less resources allocated,
       but ongoing requests are no longer disrupted.
     - Fixed an issue since 1.15.24 that "Server" headers in proxied requests
       were overwritten instead of preserved. [PR by @daum3ns]
     - A regression in v1.15.24 was fixed that could lead to httpd child
       processes not being terminated on a graceful reload or when reaching
       MaxConnectionsPerChild. When unprocessed h2 requests were queued at
       the time, these could stall. See #212.
     - Improved information displayed in 'server-status' for H2 connections when
       Extended Status is enabled. Now one can see the last request that IO
       operations happened on and transferred IO stats are updated as well.
     - When reaching server limits, such as MaxRequestsPerChild, the HTTP/2 connection
       send a GOAWAY frame much too early on new connections, leading to invalid
       protocol state and a client failing the request. See PR65731 at
       <https://bz.apache.org/bugzilla/show_bug.cgi?id=65731>.
       The module now initializes the HTTP/2 protocol correctly and allows the
       client to submit one request before the shutdown via a GOAWAY frame
       is being announced.
     - :scheme pseudo-header values, not matching the
       connection scheme, are forwarded via absolute uris to the
       http protocol processing to preserve semantics of the request.
       Checks on combinations of pseudo-headers values/absence
       have been added as described in RFC 7540. Fixes #230.
     - A bug that prevented trailers (e.g. HEADER frame at the end) to be
       generated in certain cases was fixed. See #233 where it prevented
       gRPC responses to be properly generated.
     - Request and response header values are automatically stripped of leading
       and trialing space/tab characters. This is equivalent behaviour to what
       Apache httpd's http/1.1 parser does.
       The checks for this in nghttp2 v1.50.0+ are disabled.
     - Extensive testing in production done by Alessandro Bianchi (@alexskynet)
       on the v2.0.x versions for stability. Many thanks!

  *) mod_proxy_http2: fixed #235 by no longer forwarding 'Host:' header when
     request ':authority' is known. Improved test case that did not catch that
     the previous 'fix' was incorrect.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1906475 13f79535-47bb-0310-9956-ffa450edef68
2023-01-09 07:35:18 +00:00
Jim Jagielski
a7b9ab822f Merge r1900356 from trunk:
*) mod_http2: remove unused and insecure code. Fixes PR66037.
     Thanks to Ronald Crane (Zippenhop LLC) for reporting this.


Submitted by: icing
Reviewed by: jailletc36, icing, rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1901010 13f79535-47bb-0310-9956-ffa450edef68
2022-05-17 18:19:36 +00:00
Jim Jagielski
93e3223464 Merge r from trunk:
Submitted by: icing, rpluem, ylavic
Reviewed by: jim

Github: closes #317


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1901009 13f79535-47bb-0310-9956-ffa450edef68
2022-05-17 18:17:44 +00:00
Stefan Eissing
55b993c475 merge of 1898146,1898173 from trunk:
*) mod_http2: preserve the port number given in a HTTP/1.1
     request that was Upgraded to HTTP/2. Fixes PR65881.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1898586 13f79535-47bb-0310-9956-ffa450edef68
2022-03-04 08:51:47 +00:00
Yann Ylavic
285b6285e7 ap_regex: Use Thread Local Storage (if efficient) to avoid allocations.
PCRE2 wants an opaque context by providing the API to allocate and free it, so
to minimize these calls we maintain one opaque context per thread (in Thread
Local Storage, TLS) grown as needed, and while at it we do the same for PCRE1
ints vectors. Note that this requires a fast TLS mechanism to be worth it,
which is the case of apr_thread_data_get/set() from/to apr_thread_current()
when APR_HAS_THREAD_LOCAL; otherwise we'll do the allocation and freeing for
each ap_regexec().

The small stack vector is used for PCRE1 && !APR_HAS_THREAD_LOCAL only now.


Follow up to r1897240: APR_HAS_THREAD_LOCAL wants #ifdef instead of #if.


Follow up to r1897240: CHANGES entry.


ap_regex: PCRE needs buffers sized against the number of captures only.

No more (useless), no less (or PCRE will allocate a new buffer by itself to
satisfy the needs), so we should base our buffer size solely on the number
of captures in the regex (determined at compile time from the pattern).

The nmatch provided by the user is used to fill in pmatch only (up to that),
but "our" buffers are sized exactly as needed to avoid oversized allocations
or PCRE allocating by itself.


ap_regex: Follow up to r1897244: Fix pmatch overflow and returned value at limits.

Don't write to pmatch[nlimit:] when ncaps > nmatch, rc should not exceed nmatch
either as before r1897244.


ap_regex: Follow up to r1897240: Fix issues spotted by Rüdiger (thanks!).

#include "apr_thread_proc.h" is enough/needed by util_pcre.c and main.c.
Fix compilation (vector => ovector) for !HAVE_PCRE2 && APR_HAS_THREAD_LOCAL.
Check pcre2_match_data_create() return value for HAVE_PCRE2 && !APR_HAS_THREAD_LOCAL.


ap_regex: Follow up to r1897240: runtime fallback to alloc/free.

Even though APR_HAS_THREAD_LOCAL is compiled in, ap_regexec() might still be
called by non a apr_thread_t thread, let's fall back to alloc/free in this
case too.


ap_regex: Follow up to r1897240: no ap_thread_current() yet.


ap_regex: Follow up to r1897240: cleanups.


ap_regex: Follow up to r1897240: cleanup PCRE2 match data on exit.


ap_regex: Follow up to r1897240: #if APR_HAS_THREAD_LOCAL, not #ifdef.


core: Efficient ap_thread_current() with APR < 1.8.

#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


Follow up to r1897460: APLOGNOs.


Follow up to r1897460: !APR_HAS_THREAD implies no ap_thread_* either.


core: Follow up to r1897460: Implement and use ap_thread_current_after_fork().

thread_local variables are not (always?) reset on fork(), so we need a way
to set the current_thread to NULL in the child process.

Implement and use ap_thread_current_after_fork() for that.

* include/httpd.h:
  Define ap_thread_current_after_fork().

* server/util.c:
  Implement ap_thread_current_after_fork().

* server/mpm/event/event.c, server/mpm/prefork/prefork.c,
    server/mpm/worker/worker.c:
  Use ap_thread_current_after_fork().

* server/mpm/winnt/child.c:
  Windows processes are not fork()ed and each child runs the main(), so
  ap_thread_current_create() was already called there.


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.


ap_regex: Follow up to r1897240: Fetch the ovector _after_ the match.

Possibly(?) pcre2_match() can modifiy the given pcre2_match_data and invalidate
the old ovector, be safe and fetch it after.


main: Follow up to r1897240: Fix bad log copypasta.

Don't stderr printf the "stat" and "failed" results from the previous
apr_app_initialize() call for an error in ap_thread_main_create().


core: Follow up to r1897240: Opt-out for AP_HAS_THREAD_LOCAL and/or pcre's usage.

If the compiler's thread_local is not efficient enough on some platforms, or
not desired, have a way to disable its usage in httpd (at compile time).

Handle -DAP_NO_THREAD_LOCAL and/or -DAPREG_NO_THREAD_LOCAL as build opt-out for
thread_local usage in httpd gobally and/or in ap_regex only (respectively).


core: Follow up to r1897240: Provide/export ap_thread_current_create()

For completness, and possibly to ease backport to 2.4.x for MPM winnt.


core: Follow up to r1897240 & r1897691: Syntax.


Add compiled and loaded PCRE version numbers
to "httpd -V" output and to mod_info page.


Forgotten file needed for r1612934.


Minor mmn bump due to r1612940.


Backports: r1897240, r1897241, r1897242, r1897244, r1897248, r1897250,
           r1897260, r1897261, r1897263, r1897386, r1897459, r1897460,
           r1897461, r1897462, r1897472, r1897543, r1897651, r1897680,
           r1897689, r1897691, r1897692, r1612934, r1612940, r1613189
Submitted by: ylavic, rjung, rjung, rjung
Reviewed by: ylavic, rpluem, covener, steffenal, wrowe
GH: closes #289 (https://github.com/apache/httpd/pull/289)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1898467 13f79535-47bb-0310-9956-ffa450edef68
2022-02-28 11:56:43 +00:00
Yann Ylavic
a962ba7304 Merge r1895914, r1895921 from trunk:
*) 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.
     trunk patch: http://svn.apache.org/r1895914
                  http://svn.apache.org/r1895921
     2.4.x patch: https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/286.patch
     backport PR: https://github.com/apache/httpd/pull/286
     +1: ylavic, minfrin, gbechis


mod_proxy: Detect unix: scheme syntax errors at load time.

* modules/proxy/mod_proxy.c(add_pass, add_member, set_proxy_param,
                            proxysection):
  Check return value of ap_proxy_de_socketfy().

* modules/proxy/proxy_util.c(ap_proxy_get_worker_ex):
  Check return value of ap_proxy_de_socketfy().



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.


Submitted by: ylavic
Reviewed by: ylavic, minfrin, gbechis
Closes #286


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1895955 13f79535-47bb-0310-9956-ffa450edef68
2021-12-14 15:35:56 +00:00
Graham Leggett
c1e16a6671 Backport:
*) mod_http2: fixes PR65731 and https://github.com/icing/mod_h2/issues/212
     trunk patch: na, fixed on 2.4.x source base
     backport PR: https://github.com/apache/httpd/pull/281
     +1: icing, minfrin, ylavic



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1895869 13f79535-47bb-0310-9956-ffa450edef68
2021-12-13 10:33:48 +00:00
Yann Ylavic
9ecde98131 Revert r1895807 [skip ci].
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1895808 13f79535-47bb-0310-9956-ffa450edef68
2021-12-11 12:57:53 +00:00
Yann Ylavic
4e5ec8ef75 Vote, promote [skip ci].
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1895807 13f79535-47bb-0310-9956-ffa450edef68
2021-12-11 12:56:14 +00:00
Graham Leggett
6e998eb486 Backport:
*) mod_http2: when a server is restarted gracefully, any idle h2 worker
   threads are shut down immediately.
   Also, change OpenSSL API use for deprecations in OpenSSL 3.0.
   Adds all other, never proposed code changes to make a clean
   sync of http2 sources.
   trunk patch: http://svn.apache.org/r1893214
                http://svn.apache.org/r1893215
                http://svn.apache.org/r1893220
                and other never proposed code changes
   PR: https://github.com/apache/httpd/pull/270
   +1: icing, rpluem, minfrin



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1893658 13f79535-47bb-0310-9956-ffa450edef68
2021-09-26 14:30:51 +00:00
Yann Ylavic
2fa30bf37c Merge r1892599 from trunk:
mod_http2: fixes a use-after-read of an integer value when
   passing a stream identifier for further IO checking. A
   non-issue since an int value matching no active stream
   will lead to no action.


Submitted by: icing
Reviewed by: icing, jorton, ylavic


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1892876 13f79535-47bb-0310-9956-ffa450edef68
2021-09-03 17:01:29 +00:00