use HttpClient first
This commit is contained in:
parent
4750d43c55
commit
2441981717
1 changed files with 10 additions and 12 deletions
|
@ -192,20 +192,9 @@ class Utils
|
||||||
$status = 500;
|
$status = 500;
|
||||||
$response = '';
|
$response = '';
|
||||||
$url = sprintf(self::url(), 'report');
|
$url = sprintf(self::url(), 'report');
|
||||||
|
$path = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (function_exists('curl_init')) {
|
|
||||||
if (false !== ($client = curl_init($url))) {
|
|
||||||
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($client, CURLOPT_POST, true);
|
|
||||||
curl_setopt($client, CURLOPT_POSTFIELDS, ['key' => self::key(), 'report' => $contents]);
|
|
||||||
|
|
||||||
if (false !== ($response = curl_exec($client))) {
|
|
||||||
$status = (int) curl_getinfo($client, CURLINFO_HTTP_CODE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$path = '';
|
|
||||||
if (false !== ($client = HttpClient::initClient($url, $path))) {
|
if (false !== ($client = HttpClient::initClient($url, $path))) {
|
||||||
$client->setUserAgent('Dotclear.watch ' . My::id() . '/' . self::DISTANT_API_VERSION);
|
$client->setUserAgent('Dotclear.watch ' . My::id() . '/' . self::DISTANT_API_VERSION);
|
||||||
$client->useGzip(false);
|
$client->useGzip(false);
|
||||||
|
@ -214,6 +203,15 @@ class Utils
|
||||||
|
|
||||||
$status = (int) $client->getStatus();
|
$status = (int) $client->getStatus();
|
||||||
$response = $client->getContent();
|
$response = $client->getContent();
|
||||||
|
} elseif (function_exists('curl_init')) {
|
||||||
|
if (false !== ($client = curl_init($url))) {
|
||||||
|
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($client, CURLOPT_POST, true);
|
||||||
|
curl_setopt($client, CURLOPT_POSTFIELDS, ['key' => self::key(), 'report' => $contents]);
|
||||||
|
|
||||||
|
if (false !== ($response = curl_exec($client))) {
|
||||||
|
$status = (int) curl_getinfo($client, CURLINFO_HTTP_CODE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue