From a246528eecdc5651de66ff1c2c51a8adf9f0063f Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 19 Nov 2021 14:47:51 +0100 Subject: [PATCH] Update DoPostRequest() in itoprest.examples.php to fix optional headers like in utils::DoPostRequest --- webservices/itoprest.examples.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webservices/itoprest.examples.php b/webservices/itoprest.examples.php index 5c11a7ae51..11fa793a2b 100644 --- a/webservices/itoprest.examples.php +++ b/webservices/itoprest.examples.php @@ -49,12 +49,12 @@ function DoPostRequest($sUrl, $aData, $sOptionnalHeaders = null, &$aResponseHead if ($sOptionnalHeaders !== null) { $aHeaders = explode("\n", $sOptionnalHeaders); + // N°3267 - Webservices: Fix optional headers not being taken into account + // See https://www.php.net/curl_setopt CURLOPT_HTTPHEADER + $aHTTPHeaders = array(); foreach($aHeaders as $sHeaderString) { - if(preg_match('/^([^:]): (.+)$/', $sHeaderString, $aMatches)) - { - $aHTTPHeaders[$aMatches[1]] = $aMatches[2]; - } + $aHTTPHeaders[] = trim($sHeaderString); } } // Default options, can be overloaded/extended with the 4th parameter of this method, see above $aCurlOptions