From 4db140c973dfabd7943bf7bea49718422e04509d Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Sat, 28 Jul 2018 01:22:21 -0400 Subject: [PATCH] Content encoding might be null. It doesn't really matter anyway. --- .../voxelmodpack/hdskins/skins/ValhallaSkinServer.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index 952de0e2..3ea02050 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -25,6 +25,7 @@ import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; import java.io.File; import java.io.IOException; @@ -153,11 +154,14 @@ public class ValhallaSkinServer implements SkinServer { private T readJson(HttpResponse resp, Class cl) throws IOException { String type = resp.getEntity().getContentType().getValue(); - String enc = resp.getEntity().getContentEncoding().getValue(); if (!"application/json".equals(type)) { - throw new IOException("Server returned a non-json response!"); + try { + throw new IOException("Server returned a non-json response!"); + } finally { + EntityUtils.consumeQuietly(resp.getEntity()); + } } - try (Reader r = new InputStreamReader(resp.getEntity().getContent(), enc)) { + try (Reader r = new InputStreamReader(resp.getEntity().getContent())) { if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { // TODO specific error handling throw new IOException(gson.fromJson(r, JsonObject.class).get("message").getAsString());