Hemantvc
Hemantvc

Reputation: 2119

Not getting full http response in android

I am try to get json data from ulr .

I am testing url in firefox poster add-on work fine ,getting full response .

But in android not getting full http response .

this my code

HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); // Timeout
                                                                        // Limit
HttpResponse response;
JSONObject json = new JSONObject();

try {
    HttpPost post = new HttpPost(API.ALL_PROPERTY_BUY);

    /*
     * json.put("fId", fname); json.put("fId", lname);
     */
    StringEntity se = new StringEntity(json.toString());
    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
    post.setEntity(se);
    response = client.execute(post);

    /* Checking response */
    if (response != null) {
        InputStream in = response.getEntity().getContent(); // Get the
                                                            // data in
                                                            // the
                                                            // entity
        // System.out.println("Response is:"+ in.toString());
        InputStreamReader isr = new InputStreamReader(in);
        BufferedReader br = new BufferedReader(isr);

        String s = new String();
        temps = new String();
        while ((s = br.readLine()) != null) {
            System.out.println("response is :" + s);

        }



    }


} catch (Exception e) {
    e.printStackTrace();

}

I am also search from google and try code but not solve my problem.

please any one help me.

Upvotes: 2

Views: 2762

Answers (1)

SBJ
SBJ

Reputation: 4139

try this...

    StringBuffer stringBuffer = new StringBuffer();
            while ((s = br.readLine()) != null) {
                stringBuffer.append(s);
            }

 System.out.println("response is :" + stringBuffer);

Sometimes its not print full response on console but you get full response in your variable...

Solution : Full Data not shown on Logcat or Console

Upvotes: 3

Related Questions