From 3eebc12c05e8662246fddf46fd394ee764c27a21 Mon Sep 17 00:00:00 2001 From: gggeek Date: Wed, 8 Feb 2023 16:27:52 +0000 Subject: [PATCH] be smarter about when to trigger auto usage of curl --- NEWS.md | 3 +++ src/Client.php | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5214c3f2..ac983e01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -101,6 +101,9 @@ * new: method `PhpXmlRpc::setLogger()`, to simplify injecting a custom logger into all classes of the library in one step +* improved: the Client will automatically try to use cURL for requests using Digest/NTLM auth, unless told explicitly + told not to do so via option 'use_curl' + * improved: the Client is more verbose in logging issues when trying to compress a Request for sending * improved: the `Logger` class now sports methods adhering to Psr\Log\LoggerInterface diff --git a/src/Client.php b/src/Client.php index 6292d551..7850dd99 100644 --- a/src/Client.php +++ b/src/Client.php @@ -829,10 +829,13 @@ class Client // where req is a Request $req->setDebug($this->debug); - /// @todo we could be smarter about this and force usage of curl in scenarios where it is both available and - /// needed, such as digest or ntlm auth. Do not attempt to use it for https if not present - $useCurl = ($this->use_curl == self::USE_CURL_ALWAYS) || ($this->use_curl == self::USE_CURL_AUTO && - (in_array($method, array('https', 'http11', 'h2c', 'h2')))); + /// @todo we could be smarter about this and not force usage of curl for https if not present, as well as + /// use the presence of curl_extra_opts or socket_extra_opts as a hint + $useCurl = ($this->use_curl == self::USE_CURL_ALWAYS) || ($this->use_curl == self::USE_CURL_AUTO && ( + in_array($method, array('https', 'http11', 'h2c', 'h2')) || + ($this->username != '' && $this->authtype != 1) || + ($this->proxy != '' && $this->proxy_user != '' && $this->proxy_authtype != 1) + )); // BC - we go through sendPayloadCURL/sendPayloadSocket in case some subclass reimplemented those if ($useCurl) { -- 2.47.0