-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default Accept header. #963
Conversation
According to the documentation http://devdocs.magento.com/guides/v1.0/get-started/gs-web-api-request.html#http-headers json should be the default for Accept header but if you don't send the Accept header at all an error is thrown saying "Server cannot understand Accept HTTP header media type.", this commit intention is to make application/json the default Accept for REST requests.
Thank you Pablo for reporting this issue. We will review the fix and get back |
@anupdugar Thanks for your speedy reply Anup, I will review the travis failures as soon as I can, thanks for pointing that out. |
@@ -75,7 +75,14 @@ public function getAcceptTypes() | |||
$qualityToTypes = []; | |||
$orderedTypes = []; | |||
|
|||
foreach (preg_split('/,\s*/', $this->getHeader('Accept')) as $definition) { | |||
$headerAccept = $this->getHeader('Accept'); | |||
$defaultAccept = \Magento\Webapi\Controller\Rest\Response\Renderer\Json::MIME_TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this variable?
Pablo, after a review we determined another fix that might suit this use case better. In \Magento\Webapi\Controller\Rest\Request::106 return empty($orderedTypes) ? '*/*' : array_keys($orderedTypes); Let us know your thoughts and feel free to close it if its fine. We will work on pushing this out. |
It looks good @anupdugar Thanks for the speedy merge. Cheers guys, keep up the good work! |
- Added default accept if no Accept header passed - Added api functional tests
* Various improvements: * Implemented caching for WebAPI configuration * Improved tests coverage of the CurrencySymbol module * Table catalogsearch_fulltext is setting up with ENGINE=InnoDB * Improved unit test coverage of the Catalog related functionality * Optimized JS dependencies * Refactored controller actions in the Sales module * Refactored controller actions in the Customer module * Removed the assertion for the exact number of attributes in API-functional tests for customer metadata. * Refactored API code for the CheckoutAgreements module * Refactored API code for the GiftMessage module * Refactored API for the Checkout module * Fixed bugs: * Fixed an where issue were WebAPI generated the wrong WSDL * Fixed an issue where Catalog, Checkout, Customer API ACLs did not support AJAX use case(s) * Fixed an issue where SOAP tests failed after upgrading to ZF 1.12.9 * Fixed an issue where the 'There is no data for export' message was displayed permanently after invalid search * Fixed an issue where there was no ability to set category position during creation it * Fixed a CSS issue where certain images were absent on banners () * Fixed an issue where the 'Date Of Birth' value was i reset to current date on the customer form) * Fixed an issue where the behavior of the "Terms and Conditions" validation on multiple address checkout was different from the one for the onepage checkout * Fixed an issue where it was impossible to checkout with multiple addresses * Fixed an issue where the 'This is a required field ' message was not displayed for "Terms and Conditions" if the latter was not selected * GitHub Requests: * [#963](magento/magento2#963) -- Default Accept header * [#995](magento/magento2#995) -- Prevent a warning in activated developer mode when 'plugins' is no array * [#866](magento/magento2#866) -- Configurable product attribute scope * [#965](magento/magento2#965) -- extra tests for current interception behavior * Service Contracts: * The Downloadable module basic implementation * Framework improvements: * Refactored and covered with tests the classes with high CRAP value (>50) * Moved Theme Management changes, Design changes, Design\Backend modules, and Observer components from the Core module to the Theme module * Moved Debug Hints models from the Core module to the newly added Developer module * Moved URL components, Factory, and EntityFactory from the Core module to the Magento Framework * UI improvements: * Compressed and resized images * Added new base styles for the Admin re-design * Added the WAI-ARIA attributes are to the Search Autocomplete on the storefront * Added visual style for the 'skip to content' attribute on the storefront * Fixed the style of persistent login messages on the storefront for all themes * Fixed the style of scrolling for Categories with long names in the Admin * Fixed the "css/print.css" file path on the storefront pages for all themes * Tests improvements: * Converted all fixtures/repositories for functional tests to .xml files * Improved interaction between webdriver and the new Magento JS forms * Increased unit and integration tests coverage
* Various improvements: * Implemented caching for WebAPI configuration * Improved tests coverage of the CurrencySymbol module * Table catalogsearch_fulltext is setting up with ENGINE=InnoDB * Improved unit test coverage of the Catalog related functionality * Optimized JS dependencies * Refactored controller actions in the Sales module * Refactored controller actions in the Customer module * Removed the assertion for the exact number of attributes in API-functional tests for customer metadata. * Refactored API code for the CheckoutAgreements module * Refactored API code for the GiftMessage module * Refactored API for the Checkout module * Fixed bugs: * Fixed an where issue were WebAPI generated the wrong WSDL * Fixed an issue where Catalog, Checkout, Customer API ACLs did not support AJAX use case(s) * Fixed an issue where SOAP tests failed after upgrading to ZF 1.12.9 * Fixed an issue where the 'There is no data for export' message was displayed permanently after invalid search * Fixed an issue where there was no ability to set category position during creation it * Fixed a CSS issue where certain images were absent on banners () * Fixed an issue where the 'Date Of Birth' value was i reset to current date on the customer form) * Fixed an issue where the behavior of the "Terms and Conditions" validation on multiple address checkout was different from the one for the onepage checkout * Fixed an issue where it was impossible to checkout with multiple addresses * Fixed an issue where the 'This is a required field ' message was not displayed for "Terms and Conditions" if the latter was not selected * GitHub Requests: * [#963](magento/magento2#963) -- Default Accept header * [#995](magento/magento2#995) -- Prevent a warning in activated developer mode when 'plugins' is no array * [#866](magento/magento2#866) -- Configurable product attribute scope * [#965](magento/magento2#965) -- extra tests for current interception behavior * Service Contracts: * The Downloadable module basic implementation * Framework improvements: * Refactored and covered with tests the classes with high CRAP value (>50) * Moved Theme Management changes, Design changes, Design\Backend modules, and Observer components from the Core module to the Theme module * Moved Debug Hints models from the Core module to the newly added Developer module * Moved URL components, Factory, and EntityFactory from the Core module to the Magento Framework * UI improvements: * Compressed and resized images * Added new base styles for the Admin re-design * Added the WAI-ARIA attributes are to the Search Autocomplete on the storefront * Added visual style for the 'skip to content' attribute on the storefront * Fixed the style of persistent login messages on the storefront for all themes * Fixed the style of scrolling for Categories with long names in the Admin * Fixed the "css/print.css" file path on the storefront pages for all themes * Tests improvements: * Converted all fixtures/repositories for functional tests to .xml files * Improved interaction between webdriver and the new Magento JS forms * Increased unit and integration tests coverage
[EngCom] Public Pull Requests
According to the documentation http://devdocs.magento.com/guides/v1.0/get-started/gs-web-api-request.html#http-headers json should be the default for Accept header but if you don't send the Accept header at all an error is thrown saying "Server cannot understand Accept HTTP header media type.", this commit intention is to make application/json the default Accept for REST requests.