make sure apache runs in mpm mode as http2 does not work with prefork
authorgggeek <giunta.gaetano@gmail.com>
Thu, 26 May 2022 09:47:15 +0000 (09:47 +0000)
committergggeek <giunta.gaetano@gmail.com>
Thu, 26 May 2022 09:47:15 +0000 (09:47 +0000)
src/Client.php
tests/6HTTPTest.php
tests/ci/config/apache_vhost
tests/ci/docker/entrypoint.sh
tests/ci/setup/setup_apache.sh
tests/ci/setup/setup_php.sh

index adecb1f..baaa960 100644 (file)
@@ -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
index 948117d..a1c4655 100644 (file)
@@ -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 {
 
         }
index c040f8f..9852f68 100644 (file)
@@ -2,10 +2,16 @@
 # HTTPSERVER
 # TESTS_ROOT_DIR
 
+<IfModule http2_module>
+  LogLevel http2:info
+</IfModule>
+
 <VirtualHost *:80>
 
-  # Enable http2
-  Protocols h2c http/1.1
+  <IfModule http2_module>
+    # Enable http2
+    Protocols h2c http/1.1
+  </IfModule>
 
   DocumentRoot ${TESTS_ROOT_DIR}
 
 
 <VirtualHost _default_:443>
 
-  # Enable http2
-  Protocols h2 http/1.1
+  <IfModule http2_module>
+    # Enable http2
+    Protocols h2 http/1.1
+  </IfModule>
 
   DocumentRoot ${TESTS_ROOT_DIR}
 
index e3565ab..4677393 100644 (file)
@@ -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"
index abde451..bdba955 100755 (executable)
@@ -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
 
index 038de3d..5e245bd 100755 (executable)
@@ -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