From: Gustavo Martin Morcuende Date: Tue, 30 Aug 2016 18:10:48 +0000 (+0200) Subject: CustomHTTPClient, little improvements. X-Git-Tag: weatherinformation-1.2~1^2 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=6fb392947ba9790426c337014aa7f38a0b7530ad;p=AndroidWeatherInformation CustomHTTPClient, little improvements. --- diff --git a/app/src/main/java/name/gumartinm/weather/information/httpclient/CustomHTTPClient.java b/app/src/main/java/name/gumartinm/weather/information/httpclient/CustomHTTPClient.java index 61656e5..3fd99d1 100644 --- a/app/src/main/java/name/gumartinm/weather/information/httpclient/CustomHTTPClient.java +++ b/app/src/main/java/name/gumartinm/weather/information/httpclient/CustomHTTPClient.java @@ -32,8 +32,8 @@ public class CustomHTTPClient { public String retrieveDataAsString(final URL url) throws IOException { final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestProperty("User-Agent", userAgent); try { + urlConnection.setRequestProperty("User-Agent", userAgent); final InputStream in = new BufferedInputStream(urlConnection.getInputStream()); final ByteArrayOutputStream buffer = readInputStream(in); // No easy way of retrieving the charset from urlConnection.getContentType() @@ -58,7 +58,7 @@ public class CustomHTTPClient { return byteBuffer; } - public static final CustomHTTPClient newInstance(String userAgent) { + public static final CustomHTTPClient newInstance(final String userAgent) { return new CustomHTTPClient(userAgent); } }