private <T> Mono<T> handleResponse(
            @Nullable Function<InputStream, T> responseTransformer,
            HttpClientResponse response,
            InputStream inputStream) {
        try {
            if (inputStream.available() == 0) {
                return Mono.error(new RuntimeException(
                        "HTTP response error status: "
                                + response.status()));
            }
        } catch (IOException e) {
            return Mono.error(new RuntimeException("Failed to read HTTP response payload", e));
        }
        if (!HttpUtil.isSuccess(response.status())) {
            inputStream.mark(0);
            try {
                ErrorResponse errorResponse = READER_ERROR_RESPONSE.readValue(inputStream);
                return Mono.error(new ErrorResponseException(errorResponse));
            } catch (Exception e) {
                try {
                    inputStream.reset();
                    return Mono.error(new RuntimeException(
                            "HTTP response error status: "
                                    + response.status()
                                    + ". Response payload: "
                                    + convertStreamToString(inputStream)));
                } catch (IOException ex) {
                    return Mono.error(new RuntimeException(
                            "HTTP response error status: "
                                    + response.status()));
                }
            }
        }
        if (responseTransformer == null) {
            return Mono.empty();
        }
        T responsePayload = responseTransformer.apply(inputStream);
        return Mono.just(responsePayload);
    }
@author James Chen
@implNote Don't use the Elasticsearch official implementation because:
          <p>
          1. Its jar (elasticsearch-java:8.13.0 is 11.2 MB) is unnecessarily large for our use
          cases.
          <p>
          2. Our implementation is more concise and efficient.
turms-service/src/main/java/im/turms/service/storage/elasticsearch/ElasticsearchClient.java