Expand ResponseFactory
* Factor out json_encode() call into ResponseFactory::encodeJson().
* Add createJson() and standardize on JSON for 4xx and 5xx responses
* Add methods for redirect generation, providing an HTML link in the
body as recommended by RFC 7231
Most of the code was written by Gergő Tisza. The differences compared to
I747e34faecbcd are:
* Remove JsonResponse.
* Swap parameter order of createJson() reflecting the fact that the
value is now usually provided.
* Remove unnecessary ResponseFactory::setStatus()
* Don't do ['code' => 'http500'] by default, use httpCode and httpReason
to provide that information
* In createFromReturnValue(), don't wrap numerically-indexed arrays.
* Added tests.
Bug: T223240
Change-Id: Ie185b2bd43690633f1ccbe6328a0518e43a9f2f9