httpRequestToResponse(request, message) {
    let data = removeStacktrace(request.response.toJSON());

    if (message.requestId !== data.requestId) {
      data.requestId = message.requestId;

      if (!data.raw) {
        data.content.requestId = message.requestId;
      }
    }

    debugHTTP("HTTP request response: %a", data);

    if (data.raw) {
      if (data.content === null || data.content === undefined) {
        data = "";
      } else if (typeof data.content === "object") {
        /*
         This object can be either a Buffer object, a stringified Buffer object,
         or anything else.
         In the former two cases, we create a new Buffer object, and in the
         latter, we stringify t he content.
         */
        if (
          data.content instanceof Buffer ||
          (data.content.type === "Buffer" && Array.isArray(data.content.data))
        ) {
          data = data.content;
        } else {
          data = JSON.stringify(data.content);
        }
      } else {
        // scalars are sent as strings
        data = data.content.toString();
      }
    } else {
      let indent = 0;
      const parsedUrl = url.parse(message.url, true);

      if (parsedUrl.query && parsedUrl.query.pretty !== undefined) {
        indent = 2;
      }

      data = JSON.stringify(data.content, undefined, indent);
    }

    return Buffer.from(data);
  }
Convert a Kuzzle query result into an appropriate payload format
to send back to the client

@param {Request} request
@param {HttpMessage} message
@returns {Buffer}