Skip to content

Commit

Permalink
Fixed #846 choosing GET and POST in endpoints based on body
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Jul 18, 2019
1 parent 26da9a3 commit cdbeab3
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/CountPercolate.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/FieldCaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/FieldStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Indices/Analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Indices/ValidateQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Ingest/Simulate.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/MTermVectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'POST';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Mget.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ public function getBody()
*/
public function getMethod()
{
return 'POST';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Msearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ public function getBody()
*/
public function getMethod()
{
return 'GET';
return 'POST';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/MsearchTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ public function getBody()
*/
public function getMethod()
{
return 'GET';
return 'POST';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Percolate.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public function getBody()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/RenderSearchTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public function getBody()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Scroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/SearchTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'GET';
return isset($this->body) ? 'POST' : 'GET';
}
}
2 changes: 1 addition & 1 deletion src/Elasticsearch/Endpoints/TermVectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
return 'POST';
return isset($this->body) ? 'POST' : 'GET';
}
}
3 changes: 2 additions & 1 deletion tests/Elasticsearch/Tests/Connections/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Elasticsearch\ClientBuilder;
use Elasticsearch\Connections\Connection;
use Elasticsearch\Serializers\SerializerInterface;
use Elasticsearch\Serializers\SmartSerializer;
use Psr\Log\LoggerInterface;

class ConnectionTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -38,7 +39,7 @@ function(){},

$this->assertInstanceOf(Connection::class, $connection);
}

public function testGetHeadersContainUserAgent()
{
$params = [];
Expand Down
3 changes: 0 additions & 3 deletions tests/Elasticsearch/Tests/Endpoints/StatusEndpointTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\Endpoints;

use Elasticsearch\Endpoints\Snapshot\Status;
Expand Down

0 comments on commit cdbeab3

Please sign in to comment.