From b7488577ad5d0ae35e3f4e34ba59ffc985b682d4 Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Thu, 5 Mar 2015 13:52:41 +1300 Subject: [PATCH] Downgraded Guzzle version --- code/tika/TikaRestClient.php | 34 +++++++++++++--------------------- composer.json | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/code/tika/TikaRestClient.php b/code/tika/TikaRestClient.php index d5af31b..accfa50 100644 --- a/code/tika/TikaRestClient.php +++ b/code/tika/TikaRestClient.php @@ -1,16 +1,10 @@ $url - )); - } - /** * Detect if the service is available * @@ -19,7 +13,7 @@ class TikaRestClient extends Client { public function isAvailable() { try { return $this - ->get() + ->get()->send() ->getStatusCode() == 200; } catch (RequestException $ex) { return false; @@ -32,10 +26,10 @@ class TikaRestClient extends Client { * @return float */ public function getVersion() { - $response = $this->get('version'); + $response = $this->get('version')->send(); // Parse output if($response->getStatusCode() == 200 && - preg_match('/Apache Tika (?[\.\d]+)/', $response->getBody()->getContents(), $matches) + preg_match('/Apache Tika (?[\.\d]+)/', $response->getBody(), $matches) ) { return (float)$matches['version']; } @@ -55,10 +49,9 @@ class TikaRestClient extends Client { $response = $this->get( 'mime-types', - array( - 'headers' => array("Accept" => "application/json") - ) - ); + array('Accept' => 'application/json') + )->send(); + return $this->mimes = $response->json(); } @@ -71,12 +64,11 @@ class TikaRestClient extends Client { public function tika($file) { $response = $this->put( 'tika', - array( - 'body' => file_get_contents($file), - 'headers' => array("Accept" => "text/plain") - ) - ); - return $response->getBody()->getContents(); + array('Accept' => 'text/plain'), + file_get_contents($file) + )->send(); + + return $response->getBody(true); } } diff --git a/composer.json b/composer.json index 7715180..b3b3353 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.3.2", "composer/installers": "*", "silverstripe/framework": "~3.1", - "guzzlehttp/guzzle": "~4.0" + "guzzle/guzzle": "~3.9" }, "require-dev": { "phpunit/PHPUnit": "~3.7@stable"