Change record status: 
Project: 
Introduced in branch: 
8.5.x
Introduced in version: 
8.5.0-alpha1
Description: 

In some instances it is desirable to have Drupal accept a request in one format, but respond in another.

For example, you may want to POST a file in bin format, but have Drupal respond in json format.

Prior to this change, it was possible to nominate different request and response formats via the _format and _content_type_format requirements in your route - however precedence was always given to _format for GET requests and to _content_type_format for all other requests. Which meant that if you had a route with _format = ['json'] and _content_type_format = ['bin'] (i.e. different formats) and performed a POST request in bin format, that the response would also have to be in bin format, even though _format signaled only json was supported!

After this change, if you nominate different formats for request bodies (_content_type_format) and response bodies (_format) they will be respected when \Drupal\rest\EventSubscriber\ResourceResponseSubscriber::getResponseFormat negotiates what to return, regardless of the HTTP method.

Impacts: 
Site builders, administrators, editors
Module developers