diff options
Diffstat (limited to 'src/Elasticsearch/Request.php')
| -rw-r--r-- | src/Elasticsearch/Request.php | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/src/Elasticsearch/Request.php b/src/Elasticsearch/Request.php deleted file mode 100644 index 7bb6add..0000000 --- a/src/Elasticsearch/Request.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -namespace phinde; - -class Elasticsearch_Request extends \HTTP_Request2 -{ - public $allow404 = false; - - public function send() - { - $res = parent::send(); - $mainCode = intval($res->getStatus() / 100); - if ($mainCode === 2) { - return $res; - } - - if ($this->allow404 && $res->getStatus() == 404) { - return $res; - } - $js = json_decode($res->getBody()); - if (isset($js->error)) { - $error = json_encode($js->error); - } else { - $error = $res->getBody(); - } - - throw new \Exception( - 'Error in elasticsearch communication at ' - . $this->getMethod() . ' ' . (string) $this->getUrl() - . ' (status code ' . $res->getStatus() . '): ' - . $error - ); - } -} - -?> |
