From e6197938fefedd5dbbefcf1e441b5c93f9c4bad6 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Thu, 7 Apr 2016 11:46:24 +0200 Subject: [PATCH] Read HTTP error stream before closing it It wasn't causing problems, but it looks odd. --- network/src/main/java/io/bitsquare/http/HttpClient.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/network/src/main/java/io/bitsquare/http/HttpClient.java b/network/src/main/java/io/bitsquare/http/HttpClient.java index 73eecc42e4..0c01425274 100644 --- a/network/src/main/java/io/bitsquare/http/HttpClient.java +++ b/network/src/main/java/io/bitsquare/http/HttpClient.java @@ -22,14 +22,15 @@ public class HttpClient { URL url = new URL(baseUrl + param); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); - connection.setConnectTimeout(10000); - connection.setReadTimeout(10000); + connection.setConnectTimeout(10_000); + connection.setReadTimeout(10_000); if (connection.getResponseCode() == 200) { return convertInputStreamToString(connection.getInputStream()); } else { + String error = convertInputStreamToString(connection.getErrorStream()); connection.getErrorStream().close(); - throw new HttpException(convertInputStreamToString(connection.getErrorStream())); + throw new HttpException(error); } } finally { if (connection != null)