Curl Response Refactoring

- refactored Network::post()
- replaced every Network::post() execution with the new Curl container
This commit is contained in:
Philipp Holzer 2018-10-10 21:15:26 +02:00
parent 2dec8895a9
commit 7c73e8634c
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
10 changed files with 24 additions and 25 deletions

View file

@ -1469,16 +1469,17 @@ class DFRN
$content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
$xml = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
$postResult = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
$xml = $postResult->getBody();
$curl_stat = Network::getCurl()->getCode();
$curl_stat = $postResult->getReturnCode();
if (empty($curl_stat) || empty($xml)) {
logger('Empty answer from ' . $contact['id'] . ' - ' . $dest_url);
Contact::markForArchival($contact);
return -9; // timed out
}
if (($curl_stat == 503) && (stristr(Network::getCurl()->getHeaders(), 'retry-after'))) {
if (($curl_stat == 503) && (stristr($postResult->getHeader(), 'retry-after'))) {
Contact::markForArchival($contact);
return -10;
}