File tree 3 files changed +24
-1
lines changed
app/code/Magento/Webapi/Controller/Rest
_files/Magento/TestModule1/etc
testsuite/Magento/Webapi/Routing
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class Request extends \Magento\Webapi\Controller\Request
18
18
*/
19
19
const REQUEST_CHARSET = 'utf-8 ' ;
20
20
21
+ const DEFAULT_ACCEPT = '*/* ' ;
22
+
21
23
/** @var string */
22
24
protected $ _serviceName ;
23
25
@@ -101,7 +103,7 @@ public function getAcceptTypes()
101
103
foreach ($ qualityToTypes as $ typeList ) {
102
104
$ orderedTypes += $ typeList ;
103
105
}
104
- return array_keys ($ orderedTypes );
106
+ return empty ( $ orderedTypes ) ? self :: DEFAULT_ACCEPT : array_keys ($ orderedTypes );
105
107
}
106
108
107
109
/**
Original file line number Diff line number Diff line change 52
52
<resource ref =" Magento_TestModule1::resource2" />
53
53
</resources >
54
54
</route >
55
+ <route method =" GET" url =" /V1/testmodule1/resource1/:itemId" >
56
+ <service class =" Magento\TestModule1\Service\V1\AllSoapAndRestInterface" method =" item" />
57
+ <resources >
58
+ <resource ref =" anonymous" />
59
+ </resources >
60
+ </route >
55
61
<route method =" POST" url =" /V1/testmodule1/itemAnyType" >
56
62
<service class =" Magento\TestModule1\Service\V1\AllSoapAndRestInterface" method =" itemAnyType" />
57
63
<resources >
Original file line number Diff line number Diff line change 9
9
*/
10
10
namespace Magento \Webapi \Routing ;
11
11
12
+
13
+ use Magento \TestFramework \Helper \Bootstrap ;
14
+ use Magento \TestFramework \TestCase \Webapi \Adapter \Rest \CurlClient ;
15
+
12
16
class CoreRoutingTest extends \Magento \Webapi \Routing \BaseService
13
17
{
14
18
public function testBasicRoutingExplicitPath ()
@@ -73,4 +77,15 @@ public function testExceptionSoapInternalError()
73
77
$ this ->setExpectedException ('SoapFault ' , 'Generic service exception ' );
74
78
$ this ->_webApiCall ($ serviceInfo );
75
79
}
80
+
81
+ public function testRestNoAcceptHeader ()
82
+ {
83
+ $ this ->_markTestAsRestOnly ();
84
+ /** @var $curlClient CurlClient */
85
+ $ curlClient = Bootstrap::getObjectManager ()->get (
86
+ 'Magento\TestFramework\TestCase\Webapi\Adapter\Rest\CurlClient '
87
+ );
88
+ $ response = $ curlClient ->get ('/V1/testmodule1/resource1/1 ' , [], ['Accept: ' ]);
89
+ $ this ->assertEquals ('testProduct1 ' , $ response ['name ' ], "Empty Accept header failed to return response. " );
90
+ }
76
91
}
You can’t perform that action at this time.
0 commit comments