From cbba0966dbbd24628c5d5e108b7b600a5bc02c3e Mon Sep 17 00:00:00 2001 From: gggeek Date: Thu, 26 May 2022 09:47:15 +0000 Subject: [PATCH] make sure apache runs in mpm mode as http2 does not work with prefork --- src/Client.php | 4 ++++ tests/6HTTPTest.php | 9 +++++---- tests/ci/config/apache_vhost | 16 ++++++++++++---- tests/ci/docker/entrypoint.sh | 2 ++ tests/ci/setup/setup_apache.sh | 2 +- tests/ci/setup/setup_php.sh | 6 +++++- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Client.php b/src/Client.php index adecb1fa..baaa9607 100644 --- a/src/Client.php +++ b/src/Client.php @@ -145,6 +145,8 @@ class Client * @param string $method the http protocol variant: defaults to 'http'; 'https', 'http11', 'http2' and 'http2tls' can * be used if CURL is installed. The value set here can be overridden in any call to $this->send(). * Use 'http2' to make the lib attempt to use http/2 without tls and 'http2tls' for secure http/2 + * (note that 'http2' will most likely not result in an http/2 connection in any case, as it + * seems that upgrading a POST request on the fly from http is hard or impossible) */ public function __construct($path, $server = '', $port = '', $method = '') { @@ -481,6 +483,8 @@ class Client * @param string $method valid values are 'http', 'http11', 'https', 'http2' and 'http2tls'. If left unspecified, * the http protocol chosen during creation of the object will be used. * Use 'http2' to make the lib attempt to use http/2 without tls and 'http2tls' for secure http/2 + * (note that 'http2' will most likely not result in an http/2 connection in any case, as it + * seems that upgrading a POST request on the fly from http is hard or impossible) * * @return Response|Response[] Note that the client will always return a Response object, even if the call fails * @todo allow throwing exceptions instead of returning responses in case of failed calls and/or Fault responses diff --git a/tests/6HTTPTest.php b/tests/6HTTPTest.php index 948117d5..a1c46552 100644 --- a/tests/6HTTPTest.php +++ b/tests/6HTTPTest.php @@ -325,9 +325,10 @@ class HTTPTest extends ServerTest $this->client->method = 'http2'; //$this->client->keepalive = false; // q: is this a good idea? - $this->expectHttp2 = true; + /// @todo we disable checking for HTTP2 on plain http calls, as that is unsupported for POST requests + //$this->expectHttp2 = true; $this->$method(); - $this->expectHttp2 = false; + //$this->expectHttp2 = false; } /** @@ -445,9 +446,9 @@ class HTTPTest extends ServerTest */ protected function validateResponse($r) { - /// @todo check $r->httpResponse()['protocol_version'] if ($this->expectHttp2) { - + $hr = $r->httpResponse(); + $this->assertEquals("2", $hr['protocol_version']); } else { } diff --git a/tests/ci/config/apache_vhost b/tests/ci/config/apache_vhost index c040f8f7..9852f684 100644 --- a/tests/ci/config/apache_vhost +++ b/tests/ci/config/apache_vhost @@ -2,10 +2,16 @@ # HTTPSERVER # TESTS_ROOT_DIR + + LogLevel http2:info + + - # Enable http2 - Protocols h2c http/1.1 + + # Enable http2 + Protocols h2c http/1.1 + DocumentRoot ${TESTS_ROOT_DIR} @@ -33,8 +39,10 @@ - # Enable http2 - Protocols h2 http/1.1 + + # Enable http2 + Protocols h2 http/1.1 + DocumentRoot ${TESTS_ROOT_DIR} diff --git a/tests/ci/docker/entrypoint.sh b/tests/ci/docker/entrypoint.sh index e3565abb..46773930 100644 --- a/tests/ci/docker/entrypoint.sh +++ b/tests/ci/docker/entrypoint.sh @@ -73,6 +73,8 @@ service apache2 start echo "[$(date)] Starting Privoxy..." service privoxy start +echo "[$(date)] Bootstrap finished" + tail -f /dev/null & child=$! wait "$child" diff --git a/tests/ci/setup/setup_apache.sh b/tests/ci/setup/setup_apache.sh index abde4511..bdba9550 100755 --- a/tests/ci/setup/setup_apache.sh +++ b/tests/ci/setup/setup_apache.sh @@ -2,7 +2,7 @@ # Install and configure apache2 # Has to be run as admin -# @todo make this work across all ubuntu versions (precise to focal) +# @todo make this work across all ubuntu versions (precise to jammy) set -e diff --git a/tests/ci/setup/setup_php.sh b/tests/ci/setup/setup_php.sh index 038de3d9..5e245bd4 100755 --- a/tests/ci/setup/setup_php.sh +++ b/tests/ci/setup/setup_php.sh @@ -81,8 +81,12 @@ fi service php-fpm start -# configure apache (if installed) +# reconfigure apache (if installed). Sadly, php will switch on mod-php and mpm_prefork at install time... if [ -n "$(dpkg --list | grep apache)" ]; then + # @todo silence errors in a smarter way + rm /etc/apache2/mods-enabled/php* || true + a2dismod mpm_prefork + a2enmod mpm_event a2enconf php${PHPVER}-fpm service apache2 restart fi -- 2.47.0