Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Default Accept header. #963

wants to merge 1 commit into from

Conversation

centerax
Copy link
Contributor

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.

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.
@anupdugar
Copy link
Contributor

Thank you Pablo for reporting this issue. We will review the fix and get back
In the meantime can you look at the travis failures.

@centerax
Copy link
Contributor Author

@anupdugar Thanks for your speedy reply Anup, I will review the travis failures as soon as I can, thanks for pointing that out.

@vpelipenko vpelipenko added the PS label Jan 15, 2015
@@ -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;
Copy link
Contributor

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?

@anupdugar
Copy link
Contributor

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.

@centerax
Copy link
Contributor Author

It looks good @anupdugar Thanks for the speedy merge.

Cheers guys, keep up the good work!

@centerax centerax closed this Jan 17, 2015
anupdugar added a commit that referenced this pull request Jan 30, 2015
- Added default accept if no Accept header passed
- Added api functional tests
magento-team added a commit to abeeskau/magento2-community-edition that referenced this pull request Feb 7, 2015
* 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
magento-team added a commit to abeeskau/magento2-community-edition that referenced this pull request Feb 9, 2015
* 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
magento-team pushed a commit that referenced this pull request Mar 25, 2017
magento-team pushed a commit that referenced this pull request Dec 12, 2017
 - Merge Pull Request magento-engcom/magento2ce#963 from RomaKis/magento2:8601
 - Merged commits:
   1. afafc3c
   2. f5bdc45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants