Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Aug 14, 2024
1 parent 4a7079a commit 2ec4789
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public synchronized SplitHttpResponse get(URI uri, FetchOptions options, Map<Str
}
}
public SplitHttpResponse doGet(HttpURLConnection getHttpURLConnection, FetchOptions options, Map<String, List<String>> additionalHeaders) {
InputStreamReader inputStreamReader = null;
try {
getHttpURLConnection.setRequestMethod("GET");
setBasicHeaders(getHttpURLConnection);
Expand Down Expand Up @@ -100,28 +99,21 @@ public SplitHttpResponse doGet(HttpURLConnection getHttpURLConnection, FetchOpti
statusMessage = getHttpURLConnection.getResponseMessage();
}

inputStreamReader = new InputStreamReader(getHttpURLConnection.getInputStream());
InputStreamReader inputStreamReader = new InputStreamReader(getHttpURLConnection.getInputStream());
BufferedReader br = new BufferedReader(inputStreamReader);
String strCurrentLine;
StringBuilder bld = new StringBuilder();
while ((strCurrentLine = br.readLine()) != null) {
bld.append(strCurrentLine);
}
String responseBody = bld.toString();
inputStreamReader.close();
return new SplitHttpResponse(responseCode,
statusMessage,
responseBody,
getResponseHeaders(getHttpURLConnection));
} catch (Exception e) {
throw new IllegalStateException(String.format("Problem in http get operation: %s", e), e);
} finally {
try {
if (inputStreamReader != null) {
inputStreamReader.close();
}
} catch (Exception e) {
_log.error(String.format("Could not close HTTP Stream: %s", e), e);
}
}
}

Expand Down

0 comments on commit 2ec4789

Please sign in to comment.