aboutsummaryrefslogtreecommitdiff
path: root/src/phinde/Elasticsearch
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2020-02-29 21:16:44 +0100
committerChristian Weiske <cweiske@cweiske.de>2020-02-29 21:16:44 +0100
commit18d36cb052c42c20edda2814545c9bdf3fb1cbc5 (patch)
treed6ebd28dd7c575ba4e1c8b6eb4ad5a503e7884c6 /src/phinde/Elasticsearch
parente8e4778a7550636790d7b33d96a83bbbd3ac21ae (diff)
downloadphinde-elastic6.tar.gz
phinde-elastic6.zip
Diffstat (limited to 'src/phinde/Elasticsearch')
-rw-r--r--src/phinde/Elasticsearch/Request.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/phinde/Elasticsearch/Request.php b/src/phinde/Elasticsearch/Request.php
index 7bb6add..1f9cd99 100644
--- a/src/phinde/Elasticsearch/Request.php
+++ b/src/phinde/Elasticsearch/Request.php
@@ -30,6 +30,24 @@ class Elasticsearch_Request extends \HTTP_Request2
. $error
);
}
-}
+ /**
+ * Sets the request body - inject content type
+ *
+ * @param mixed $body Either a string with the body or filename
+ * containing body or pointer to an open file or
+ * object with multipart body data
+ * @param bool $isFilename Whether first parameter is a filename
+ *
+ * @return HTTP_Request2
+ * @throws HTTP_Request2_LogicException
+ *
+ * @link https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests
+ */
+ public function setBody($body, $isFilename = false)
+ {
+ $this->setHeader('content-type', 'application/json');
+ return parent::setBody($body, $isFilename);
+ }
+}
?>