From: gggeek Date: Sun, 27 Nov 2022 14:31:04 +0000 (+0000) Subject: add http2 support to the debugger X-Git-Tag: 4.9.0~7 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=80cfcb6479e58f822e38ea8cd00841e555c1df77;p=plcapi.git add http2 support to the debugger --- diff --git a/debugger/action.php b/debugger/action.php index 7e35a22e..64b2d5e4 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -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 == '' ) { diff --git a/debugger/common.php b/debugger/common.php index d6e43fe0..3f9add21 100644 --- a/debugger/common.php +++ b/debugger/common.php @@ -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'] : ''; diff --git a/debugger/controller.php b/debugger/controller.php index 1501ac03..f110cc74 100644 --- a/debugger/controller.php +++ b/debugger/controller.php @@ -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/ + +