def handle_backend_response(self, orig_request, backend_request,
                              response_status, response_headers,
                              response_body, method_config, start_response):
    """Handle backend response, transforming output as needed.

    This calls start_response and returns the response body.

    Args:
      orig_request: An ApiRequest, the original request from the user.
      backend_request: An ApiRequest, the transformed request that was
                       sent to the backend handler.
      response_status: A string, the status from the response.
      response_headers: A dict, the headers from the response.
      response_body: A string, the body of the response.
      method_config: A dict, the API config of the method to be called.
      start_response: A function with semantics defined in PEP-333.

    Returns:
      A string containing the response body.
    """
    # Verify that the response is json.  If it isn't treat, the body as an
    # error message and wrap it in a json error response.
    for header, value in response_headers:
      if (header.lower() == 'content-type' and
          not value.lower().startswith('application/json')):
        return self.fail_request(orig_request,
                                 'Non-JSON reply: %s' % response_body,
                                 start_response)

    self.check_error_response(response_body, response_status)

    # Check if the response from the API was empty.  Empty REST responses
    # generate a HTTP 204.
    empty_response = self.check_empty_response(orig_request, method_config,
                                                 start_response)
    if empty_response is not None:
      return empty_response

    body = self.transform_rest_response(response_body)

    cors_handler = self._create_cors_handler(orig_request)
    return util.send_wsgi_response(response_status, response_headers, body,
                                   start_response, cors_handler=cors_handler)
Handle backend response, transforming output as needed.

    This calls start_response and returns the response body.

    Args:
      orig_request: An ApiRequest, the original request from the user.
      backend_request: An ApiRequest, the transformed request that was
                       sent to the backend handler.
      response_status: A string, the status from the response.
      response_headers: A dict, the headers from the response.
      response_body: A string, the body of the response.
      method_config: A dict, the API config of the method to be called.
      start_response: A function with semantics defined in PEP-333.

    Returns:
      A string containing the response body.