From 67a1c40476474ad741a26e067f437f1e31392ded Mon Sep 17 00:00:00 2001 From: Mukunda Modell Date: Thu, 30 Mar 2017 18:07:47 +0000 Subject: [PATCH] Set content-type to application/json Summary: Elasticsearch really wants a raw json body and it fails to accept the request as of es version 5.3 Test Plan: Tested with elasticsearch 5.2 and 5.3. Before this change 5.2 worked but 5.3 failed with `HTTP/406 "Content-Type header [application/x-www-form-urlencoded] is not supported"` [1] After this change, both worked. [1] https://phabricator.wikimedia.org/P5158 Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17580 --- .../fulltextstorage/PhabricatorElasticFulltextStorageEngine.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php index aa966caddc..2e456ec408 100644 --- a/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php +++ b/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php @@ -551,6 +551,8 @@ class PhabricatorElasticFulltextStorageEngine $uri = $host->getURI($path); $data = phutil_json_encode($data); $future = new HTTPSFuture($uri, $data); + $future->addHeader('Content-Type', 'application/json'); + if ($method != 'GET') { $future->setMethod($method); }