Update DoPostRequest() in itoprest.examples.php to fix optional headers like in utils::DoPostRequest

This commit is contained in:
Molkobain
2021-11-19 14:47:51 +01:00
parent 7fbbf1088a
commit a246528eec

View File

@@ -49,12 +49,12 @@ function DoPostRequest($sUrl, $aData, $sOptionnalHeaders = null, &$aResponseHead
if ($sOptionnalHeaders !== null) if ($sOptionnalHeaders !== null)
{ {
$aHeaders = explode("\n", $sOptionnalHeaders); $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) foreach($aHeaders as $sHeaderString)
{ {
if(preg_match('/^([^:]): (.+)$/', $sHeaderString, $aMatches)) $aHTTPHeaders[] = trim($sHeaderString);
{
$aHTTPHeaders[$aMatches[1]] = $aMatches[2];
}
} }
} }
// Default options, can be overloaded/extended with the 4th parameter of this method, see above $aCurlOptions // Default options, can be overloaded/extended with the 4th parameter of this method, see above $aCurlOptions