Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions web-clients/src/main/java/org/bahmni/webclients/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ public <T, R> R post(String url, T payload, Class<R> returnType) throws IOExcept
private void checkSanityOfResponse(HttpResponse httpResponse) {
StatusLine statusLine = httpResponse.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode < 200 || statusCode >= 300) throw new WebClientsException("Bad response code of " + statusCode);

HttpEntity entity = httpResponse.getEntity();
if (statusCode < 200 || statusCode >= 300) {
try {
EntityUtils.consume(entity);
} catch (IOException e) {
throw new WebClientsException("Unable to read response entity", e);
}
throw new WebClientsException("Bad response code of " + statusCode);
}

if (entity == null) throw new WebClientsException("Cannot read response");
}

Expand Down