diff --git a/app/code/Magento/Webapi/Controller/Rest/Request.php b/app/code/Magento/Webapi/Controller/Rest/Request.php index bb7c316fd35ad..ca4e3164635c6 100644 --- a/app/code/Magento/Webapi/Controller/Rest/Request.php +++ b/app/code/Magento/Webapi/Controller/Rest/Request.php @@ -18,6 +18,8 @@ class Request extends \Magento\Webapi\Controller\Request */ const REQUEST_CHARSET = 'utf-8'; + const DEFAULT_ACCEPT = '*/*'; + /** @var string */ protected $_serviceName; @@ -101,7 +103,7 @@ public function getAcceptTypes() foreach ($qualityToTypes as $typeList) { $orderedTypes += $typeList; } - return array_keys($orderedTypes); + return empty($orderedTypes) ? self::DEFAULT_ACCEPT : array_keys($orderedTypes); } /** diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/etc/webapi.xml b/dev/tests/api-functional/_files/Magento/TestModule1/etc/webapi.xml index 730cf6b892aaf..c73e035fdac15 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/etc/webapi.xml +++ b/dev/tests/api-functional/_files/Magento/TestModule1/etc/webapi.xml @@ -52,6 +52,12 @@ + + + + + + diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php index 978ceab1c9689..7a05ee6be2567 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/CoreRoutingTest.php @@ -9,6 +9,10 @@ */ namespace Magento\Webapi\Routing; + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient; + class CoreRoutingTest extends \Magento\Webapi\Routing\BaseService { public function testBasicRoutingExplicitPath() @@ -73,4 +77,15 @@ public function testExceptionSoapInternalError() $this->setExpectedException('SoapFault', 'Generic service exception'); $this->_webApiCall($serviceInfo); } + + public function testRestNoAcceptHeader() + { + $this->_markTestAsRestOnly(); + /** @var $curlClient CurlClient */ + $curlClient = Bootstrap::getObjectManager()->get( + 'Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient' + ); + $response = $curlClient->get('/V1/testmodule1/resource1/1', [], ['Accept:']); + $this->assertEquals('testProduct1', $response['name'], "Empty Accept header failed to return response."); + } }