Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2 websockets backport for 2.4.x #366

Closed
wants to merge 32 commits into from
Closed

Conversation

icing
Copy link
Contributor

@icing icing commented Jun 29, 2023

Based on #364

  • core: add ap_get_pollfd_from_conn(), increment mmn number

  • mod_http2:

    • add support for bootstrapping WebSockets via HTTP/2, as described
      in RFC 8441.
    • 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.
    • small optimisation for output passing when sending DATA frames
    • 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.
  • tests: add websocket tests, requires python websockets module version 10.4 or newer

modules/proxy/proxy_util.c Outdated Show resolved Hide resolved
include/ap_mmn.h Show resolved Hide resolved
modules/http2/h2_c2_filter.c Show resolved Hide resolved
modules/http2/h2_c2_filter.c Outdated Show resolved Hide resolved
modules/http2/h2_c2_filter.c Outdated Show resolved Hide resolved
modules/http2/h2_proxy_util.c Outdated Show resolved Hide resolved
modules/http2/h2_util.c Show resolved Hide resolved
modules/http2/h2_util.c Show resolved Hide resolved
modules/http2/h2_util.c Show resolved Hide resolved
modules/http2/h2_util.h Outdated Show resolved Hide resolved
modules/http2/h2_ws.c Outdated Show resolved Hide resolved
include/ap_mmn.h Outdated Show resolved Hide resolved
@icing
Copy link
Contributor Author

icing commented Aug 23, 2023

Many thanks for reviewing and finding mistakes. Just pushed the changes.

icing and others added 23 commits August 23, 2023 16:06
  *) 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.
  *) 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 apache#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.
 * 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.
  *) 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.
     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
     server versions. Give error message accordingly when trying to
     enable websockets in unsupported configurations.
     Add test and code to check the, finally selected, server of
     a request_rec for websocket support or 501 the request.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910535 13f79535-47bb-0310-9956-ffa450edef68
           next DATA frame for a response.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910648 13f79535-47bb-0310-9956-ffa450edef68
     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/trunk@1910656 13f79535-47bb-0310-9956-ffa450edef68
… test.

So ignore it, and move the _fail_proto test first to avoid messing up with
the error logs of the other tests.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910667 13f79535-47bb-0310-9956-ffa450edef68
are populated (best effort) for the response generation since this
might access fields in there.
Respect a http_status already assigned during stream processing
for error generation.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910686 13f79535-47bb-0310-9956-ffa450edef68
       client and origin as timeout for polling the tunnel.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910704 13f79535-47bb-0310-9956-ffa450edef68
take the large of client/origin values.

Add websocket test to verify that longer proxypass timeout is in
effect.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910809 13f79535-47bb-0310-9956-ffa450edef68
- provide "Connection" header in internal Upgrade request
- set input notification if input is already available when
 stream processing is started
- add optional function in mod_http2.h to use instead of
 ap_get_pollfd_from_conn() in older servers with a new
 mod_http2
- re-add ap_mmn comment for 128 minor version
- reverted most changes of apr_strnatcasecmp() to ap_cstr_casecmp()
  since the former has special whitespace handling which *may* mattter
  in certain cases
- fixed log message when wrong Sec-WebSocket-Accept response
  header was found
modules/http2/h2_c2.c Outdated Show resolved Hide resolved
@rpluem
Copy link
Contributor

rpluem commented Aug 28, 2023

As this PR touches the HTTP/2 implementation I think it should pass the HTTP/2 test suite.

- eliminiate 712_03 as being then really the same as 712_02
@icing
Copy link
Contributor Author

icing commented Aug 28, 2023

As this PR touches the HTTP/2 implementation I think it should pass the HTTP/2 test suite.

The HTTP/2 test suite should be more reliable, even when CPU resources are scarce. Pushed a fix.

@icing
Copy link
Contributor Author

icing commented Aug 28, 2023

github runner seem to have a Monday. Fixed the failure in test_h2_600_32 in trunk r1911964.

@icing
Copy link
Contributor Author

icing commented Sep 28, 2023

Merged to 2.4.x in r1911979.

@icing icing closed this Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants