add http2 support to the debugger
authorgggeek <giunta.gaetano@gmail.com>
Sun, 27 Nov 2022 14:31:04 +0000 (14:31 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sun, 27 Nov 2022 14:31:04 +0000 (14:31 +0000)
debugger/action.php
debugger/common.php
debugger/controller.php

index 7e35a22..64b2d5e 100644 (file)
@@ -122,7 +122,7 @@ if ($action) {
         $client = new $clientClass($path, $host);
         $server = "$host$path";
     }
-    if ($protocol == 2) {
+    if ($protocol == 2 || $protocol == 3) {
         $server = 'https://' . $server;
     } else {
         $server = 'http://' . $server;
@@ -137,13 +137,19 @@ if ($action) {
         $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd);
     }
 
-    if ($protocol == 2) {
+    if ($protocol == 2 || $protocol == 3) {
         $client->setSSLVerifyPeer($verifypeer);
         $client->setSSLVerifyHost($verifyhost);
         if ($cainfo) {
             $client->setCaCertificate($cainfo);
         }
-        $httpprotocol = 'https';
+        if ($protocol == 3) {
+            $httpprotocol = 'h2';
+        } else {
+            $httpprotocol = 'https';
+        }
+    } elseif ($protocol == 4) {
+        $httpprotocol = 'h2c';
     } elseif ($protocol == 1) {
         $httpprotocol = 'http11';
     } else {
@@ -474,7 +480,7 @@ if ($action) {
                         $encoder = new PhpXmlRpc\Encoder();
                         $msig = $encoder->decode($r2);
                         $msig = $msig[$methodsig];
-                        $proto = $protocol == 2 ? 'https' : ( $protocol == 1 ? 'http11' : '' );
+                        $proto = ($protocol == 1) ? 'http11' : ( $protocol == 2 ? 'https' : ( $protocol == 3 ? 'h2' : ( $protocol == 4 ? 'h2c' : '' ) ) );
                         if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression &&
                             $clientcookies == ''
                         ) {
index d6e43fe..3f9add2 100644 (file)
@@ -86,14 +86,19 @@ if (isset($_GET['action'])) {
         }
     }
     $host = isset($_GET['host']) ? $_GET['host'] : 'localhost'; // using '' will trigger an xmlrpc error...
-    if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2')) {
+    if (isset($_GET['protocol']) && ($_GET['protocol'] == '1' || $_GET['protocol'] == '2' || $_GET['protocol'] == '3')
+        || $_GET['protocol'] == '4') {
         $protocol = $_GET['protocol'];
     }
     if (strpos($host, 'http://') === 0) {
+        // NB: if protocol is https or h2, it will override http://
         $host = substr($host, 7);
     } elseif (strpos($host, 'https://') === 0) {
         $host = substr($host, 8);
-        $protocol = 2;
+        // NB: otoh if protocol is http1.0 or http1.1, it will be overridden by https://
+        if ($protocol == 0 || $protocol = 1) {
+            $protocol = 2;
+        }
     }
     $port = isset($_GET['port']) ? $_GET['port'] : '';
     $path = isset($_GET['path']) ? $_GET['path'] : '';
index 1501ac0..f110cc7 100644 (file)
@@ -142,7 +142,7 @@ $editorlibs = (defined('JSXMLRPC_PATH') ? JSXMLRPC_PATH : '../..') . '/jsxmlrpc/
         }
 
         function switchssl() {
-            if (document.frmaction.protocol.value != '2') {
+            if (document.frmaction.protocol.value != '2' && document.frmaction.protocol.value != '3') {
                 document.frmaction.verifypeer.disabled = true;
                 document.frmaction.verifyhost.disabled = true;
                 document.frmaction.cainfo.disabled = true;
@@ -294,6 +294,8 @@ $editorlibs = (defined('JSXMLRPC_PATH') ? JSXMLRPC_PATH : '../..') . '/jsxmlrpc/
                     <option value="0"<?php if ($protocol == 0) { echo ' selected="selected"'; } ?>>HTTP 1.0</option>
                     <option value="1"<?php if ($protocol == 1) { echo ' selected="selected"'; } ?>>HTTP 1.1</option>
                     <option value="2"<?php if ($protocol == 2) { echo ' selected="selected"'; } ?>>HTTPS</option>
+                    <option value="3"<?php if ($protocol == 3) { echo ' selected="selected"'; } ?>>HTTP2</option>
+                    <option value="4"<?php if ($protocol == 3) { echo ' selected="selected"'; } ?>>HTTP2 no TLS</option>
                 </select></td>
         </tr>
         <tr>