mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Content encoding might be null. It doesn't really matter anyway.
This commit is contained in:
parent
b86403ae65
commit
4db140c973
1 changed files with 7 additions and 3 deletions
|
@ -25,6 +25,7 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -153,11 +154,14 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
|
|
||||||
private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException {
|
private <T> T readJson(HttpResponse resp, Class<T> cl) throws IOException {
|
||||||
String type = resp.getEntity().getContentType().getValue();
|
String type = resp.getEntity().getContentType().getValue();
|
||||||
String enc = resp.getEntity().getContentEncoding().getValue();
|
|
||||||
if (!"application/json".equals(type)) {
|
if (!"application/json".equals(type)) {
|
||||||
|
try {
|
||||||
throw new IOException("Server returned a non-json response!");
|
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) {
|
if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||||
// TODO specific error handling
|
// TODO specific error handling
|
||||||
throw new IOException(gson.fromJson(r, JsonObject.class).get("message").getAsString());
|
throw new IOException(gson.fromJson(r, JsonObject.class).get("message").getAsString());
|
||||||
|
|
Loading…
Reference in a new issue