Anomalie #14175 » CurlModel.diff
src/core/models/CurlModel.php | ||
---|---|---|
ValidatorModel::notEmpty($aArgs, ['xmlPostString', 'url']);
|
||
ValidatorModel::stringType($aArgs, ['xmlPostString', 'url', 'soapAction']);
|
||
ValidatorModel::arrayType($aArgs, ['options']);
|
||
$opts = [
|
||
CURLOPT_URL => $aArgs['url'],
|
||
CURLOPT_RETURNTRANSFER => true,
|
||
... | ... | |
$curl = curl_init();
|
||
curl_setopt_array($curl, $opts);
|
||
$rawResponse = curl_exec($curl);
|
||
$error = curl_error($curl);
|
||
$infos = curl_getinfo($curl);
|
||
$cookies = [];
|
||
if (!empty($aArgs['options'][CURLOPT_HEADER])) {
|
||
preg_match_all('/Set-Cookie:\s*([;]*)/mi', $rawResponse, $matches);
|
||
//preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $rawResponse, $matches);
|
||
foreach ($matches[1] as $item) {
|
||
$cookie = explode("=", $item);
|
||
$cookies = array_merge($cookies, [$cookie[0] => $cookie[1]]);
|
||
}
|
||
$rawResponse = substr($rawResponse, $infos['header_size']);
|
||
} elseif (!empty($aArgs['delete_header'])) { // Delete header for iparapheur
|
||
$body = explode(PHP_EOL . PHP_EOL, $rawResponse)[1]; // put the header ahead
|
||
$body = strstr($rawResponse, '<?xml');
|
||
//$body = explode(PHP_EOL . PHP_EOL, $rawResponse)[1]; // put the header ahead
|
||
if (empty($body)) {
|
||
$body = explode(PHP_EOL, $rawResponse);
|
||
// we remove the 4 starting item of the array (header)
|
||
... | ... | |
]);
|
||
}
|
||
return ['response' => simplexml_load_string($rawResponse), 'infos' => $infos, 'cookies' => $cookies, 'raw' => $rawResponse, 'error' => $error];
|
||
/*$testXml = simplexml_load_string($rawResponse);
|
||
if ($testXml === false) {
|
||
echo 'error XML' . PHP_EOL;
|
||
var_dump($rawResponse);
|
||
$rawResponse = "<?xml version='1.0'><ROOT><S:Envelope><S:Body><ns2:GetHistoDossierResponse><ns2:LogDossier><ns2:annotation>" . $rawResponse . "</ROOT>";
|
||
return ['response' => simplexml_load_string($rawResponse), 'infos' => $infos, 'cookies' => $cookies, 'raw' => $rawResponse, 'error' => $error];
|
||
//return false;
|
||
} else {*/
|
||
return ['response' => simplexml_load_string($rawResponse), 'infos' => $infos, 'cookies' => $cookies, 'raw' => $rawResponse, 'error' => $error];
|
||
//}
|
||
}
|
||
public static function getConfigByCallId(array $aArgs)
|