Skip to content

Commit 6075dc1

Browse files
committed
Use a faster cURL package
1 parent 162e3dd commit 6075dc1

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

composer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">=5.4",
25-
"guzzlehttp/guzzle": "~6.0"
26-
}
24+
"php": ">=5.4.0",
25+
"jleagle/curl-wrapper": "~0.1",
26+
"packaged/helpers": "~1.1"
27+
},
28+
"repositories": [
29+
{
30+
"type": "vcs",
31+
"url": "[email protected]:jleagle/curl-wrapper.git"
32+
}
33+
]
2734
}

src/SickBeard.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22
namespace Jleagle\SickBeard;
33

4-
use GuzzleHttp\Client as Guzzle;
4+
use Jleagle\CurlWrapper\Curl;
55
use Jleagle\SickBeard\Enums\FutureSortEnum;
66
use Jleagle\SickBeard\Enums\LanguageEnum;
77
use Jleagle\SickBeard\Enums\LogEnum;
88
use Jleagle\SickBeard\Enums\ShowsSortEnum;
99
use Jleagle\SickBeard\Enums\SortOrderEnum;
1010
use Jleagle\SickBeard\Exceptions\SickBeardException;
11+
use Packaged\Helpers\Strings;
1112

1213
class SickBeard
1314
{
@@ -749,23 +750,20 @@ protected function _request($params)
749750
$params['callback'] = $this->_callback;
750751
}
751752

752-
$url = $this->_url . '/api/' . $this->_apiKey . '/?';
753-
$query = http_build_query($params);
753+
$url = $this->_url . '/api/' . $this->_apiKey;
754754

755-
$client = new Guzzle();
756-
$response = $client->get($url . $query);
755+
$response = Curl::get($url, $params)->run();
757756

758-
if($response->getStatusCode() != 200)
757+
if($response->getHttpCode() != 200)
759758
{
760759
throw new SickBeardException('Invalid response');
761760
}
762761

763-
$body = $response->getBody();
764-
$contentType = $response->getHeader('content-type');
762+
$contentType = $response->getContentType();
765763

766-
if(strpos($contentType[0], 'json') !== false)
764+
if(Strings::contains($contentType, 'json', false))
767765
{
768-
$array = json_decode($body, true);
766+
$array = $response->getJson();
769767

770768
if(isset($array['result']) && $array['result'] != 'success')
771769
{
@@ -776,8 +774,8 @@ protected function _request($params)
776774
}
777775
else
778776
{
779-
header('Content-Type: ' . $contentType[0]);
780-
return $body;
777+
header('Content-Type: ' . $contentType);
778+
return $response->getOutput();
781779
}
782780
}
783781

0 commit comments

Comments
 (0)