I've managed to make changes to everything but the following:
HttpClient client;
HttpPost method;
client = new DefaultHttpClient();
method = new HttpPost(url);
InputStream rstream;
try {
rstream = method.getResponseBodyAsStream();
} catch (IOException e) {
return BadSpot(e.getMessage());
}
What I'm not sure of is what I should replace getResponseBodyAsStream() with.
HttpResponse.getEntity(), followed by HttpEntity.getContent()
above should do what you are asking.
The util class has some helpful methods:
There is also some useful stuff in the examples at apache's website
Use
EntityUtils
and check the returned entity to benot null
before consuming the entity:NOTE: the InputStream here can be null and most of all you have to ensure that it's consumed before you actually close the response/release the connection.