presto-client/src/main/java/io/prestosql/client/JsonResponse.java/JsonResponse/execute
class JsonResponse:    public static <T> JsonResponse<T> execute(JsonCodec<T> codec, OkHttpClient client, Request request)
    {
        try (Response response = client.newCall(request).execute()) {
            // TODO: fix in OkHttp: https://github.com/square/okhttp/issues/3111
            if ((response.code() == 307) || (response.code() == 308)) {
                String location = response.header(LOCATION);
                if (location != null) {
                    request = request.newBuilder().url(location).build();
                    return execute(codec, client, request);
                }
            }

            ResponseBody responseBody = requireNonNull(response.body());
            String body = responseBody.string();
            if (isJson(responseBody.contentType())) {
                return new JsonResponse<>(response.code(), response.message(), response.headers(), body, codec);
            }
            return new JsonResponse<>(response.code(), response.message(), response.headers(), body);
        }
        catch (IOException e) {
            // OkHttp throws this after clearing the interrupt status
            // TODO: remove after updating to Okio 1.15.0+
            if ((e instanceof InterruptedIOException) && "thread interrupted".equals(e.getMessage())) {
                Thread.currentThread().interrupt();
            }
            throw new UncheckedIOException(e);
        }
    }