Android Utililty Methods HttpResponse Read

List of utility methods to do HttpResponse Read

Description

The list of methods to do HttpResponse Read are organized into topic(s).

Method

booleanreadBody(HttpResponse resp, ByteBuffer target)
read Body
final HttpEntity entity = resp.getEntity();
if (entity == null) {
    throw new IllegalArgumentException(
            "HTTP entity may not be null");
final InputStream is = entity.getContent();
if (is == null) {
    return false;
...
JSONObjectdecodeJSONResponse(HttpResponse resp)
decode JSON Response
InputStream is = null;
try {
    is = resp.getEntity().getContent();
} catch (IOException e) {
    Log.d(TAG, "unable to get content from response entity");
    e.printStackTrace();
    return null;
String in = convertStreamToString(is);
JSONObject json = null;
try {
    json = new JSONObject(in);
} catch (JSONException e) {
    Log.d(TAG, "could not decode JSON response from: " + in);
return json;
MaphandleJsonResponse(HttpResponse response)
handle Json Response
JSONObject oauthLoginResponse = null;
String contentType = response.getEntity().getContentType()
        .getValue();
try {
    oauthLoginResponse = new JSONObject(
            EntityUtils.toString(response.getEntity()));
} catch (ParseException e1) {
    e1.printStackTrace();
...