RequestInterface should have a getParsedBody method (and a matching setParsedBody method), implemented in RequestBase. The REST framework should ensure that the parsed body is populated if the request body is JSON or form data.
Motivation: This will allow us to implement a solution for T305973 in a stright-forward way. It also improves parity with PSR-7.
Implementation notes:
- The Router class should call setParsedBody() close to where it already calls setPathParams() on the request object.
- The actualy parsing of the body data should be implemented on in parseBodyData() method on the Handler base class, so concrete handlers can add supported formats, or opt out of body parsing by returnign null. Handlers that have body parsing disabled by process in request body as a stream by calling RequestInterface::getBox().
- PSR-7 requires getParsedBody to also work for form data. So requests that have application/x-www-form-urlencoded or multipart/form-data bodies, getParsedBody() must return the same thing as getPostParams(). To support this, it will be useful to add a getBodyType() method to RequestInterface(), which provides convenient access to the body's content model. The implementation of that method should follow the code currently located in Validator::validateBody().
- RequestData should support setting the parsed body in the constructor, using the key 'parsedBody'.