From e296d87376617136881cec2a2187e9316ce4e0b0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 7 Sep 2018 19:50:44 +0200 Subject: [PATCH] Add a bytes() method for MoreHttpResponses --- .../com/voxelmodpack/hdskins/util/MoreHttpResponses.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/util/MoreHttpResponses.java b/src/hdskins/java/com/voxelmodpack/hdskins/util/MoreHttpResponses.java index 22502be8..2246331d 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/util/MoreHttpResponses.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/util/MoreHttpResponses.java @@ -1,5 +1,6 @@ package com.voxelmodpack.hdskins.util; +import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; import com.google.gson.JsonObject; import com.voxelmodpack.hdskins.server.SkinServer; @@ -48,6 +49,12 @@ public interface MoreHttpResponses extends AutoCloseable { return new BufferedReader(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8)); } + default byte[] bytes() throws IOException { + try (InputStream input = getInputStream()) { + return ByteStreams.toByteArray(input); + } + } + default String text() throws IOException { try (BufferedReader reader = getReader()) { return CharStreams.toString(reader);