Curl Response Refactoring
- extended Curl to parse Curl Response - refactored Network::curl() - replaced every Network::curl() execution with the new Curl container
This commit is contained in:
@@ -185,18 +185,17 @@ class OnePoll
|
||||
. '&type=data&last_update=' . $last_update
|
||||
. '&perm=' . $perm ;
|
||||
|
||||
$ret = Network::curl($url);
|
||||
$curlResult = Network::curl($url);
|
||||
|
||||
if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) {
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
||||
$handshake_xml = $ret['body'];
|
||||
|
||||
$html_code = Network::getCurl()->getCode();
|
||||
$handshake_xml = $curlResult->getBody();
|
||||
$html_code = $curlResult->getReturnCode();
|
||||
|
||||
logger('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
|
||||
|
||||
@@ -319,17 +318,17 @@ class OnePoll
|
||||
}
|
||||
|
||||
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
|
||||
$ret = Network::curl($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]);
|
||||
$curlResult = Network::curl($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]);
|
||||
unlink($cookiejar);
|
||||
|
||||
if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
if (!$curlResult->isTimeout()) {
|
||||
// set the last-update so we don't keep polling
|
||||
DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
||||
$xml = $ret['body'];
|
||||
$xml = $curlResult->getBody();
|
||||
|
||||
} elseif ($contact['network'] === Protocol::MAIL) {
|
||||
logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
|
||||
|
||||
Reference in New Issue
Block a user