Error In Http Connection Java.lang.illegalstateexception Content Has Been Consumed
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Android HttpResponse - Content has been consumed up vote 5 down vote favorite 1 The method below falls over when reading the HttpResponse with the error: "Content has been consumed". I understand that the content can only be consumed once but I get this error on the very first attempt and I don't see anywhere in the code where I'm possibly consuming it twice. private static String getData(String url, HttpParams params) { StringBuilder builder = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); if (params != null) { httpGet.setParams(params); } String result = ""; try { HttpResponse response = client.execute(httpGet); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode == 200) { HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } content.close(); result = builder.toString(); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return result; } android httpresponse share|improve this question edited Apr 28 at 15:53 madhead 7,94354787 asked Apr 16 '12 at 4:08 JBehrendt 5727 are you sure exception is being generated into only this block of code –jeet Apr 16 '12 at 4:15 What is the result of calling isStreaming on your response entity? &ndash
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads http://stackoverflow.com/questions/10168617/android-httpresponse-content-has-been-consumed with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/5906890/illegalstateexception-content-has-been-consumed up IllegalStateException: Content has been consumed up vote 1 down vote favorite class VideoUploadTask extends AsyncTask
have already extracted the content somewhere, and you try to fetch it again, it will throw this IllegalStateException. Check you code and make http://osdir.com/ml/Android-Developers/2010-07/msg04043.html sure that you make this call only once. - Kumar Bibek http://tech-droid.blogspot.com On Jul 23, 1:23 pm, tarun agarwal
for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Salesforce Questions Tags Users Badges Unanswered Ask Question _ Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Salesforce SDK error: java.lang.IllegalStateException: Content has been consumed up vote 1 down vote favorite I have developed a android application using the Salesforce SDK. I am facing an odd issue, when the same user or different user logs on 3 to 4 times then logs out of application immediately. I would then get “java.lang.IllegalStateException: Content has been consumed” error thrown by the volly.jar library. Can any one help me with this issue? Here is the detailed log for reference: java.lang.IllegalStateException: Content has been consumed 12-17 15:28:53.630: E/Volley(22192): at org.apache.http.entity.BasicHttpEntity.getContent(BasicHttpEntity.java:84) 12-17 15:28:53.630: E/Volley(22192): at org.apache.http.conn.BasicManagedEntity.getContent(BasicManagedEntity.java:100) 12-17 15:28:53.630: E/Volley(22192): at android.net.http.AndroidHttpClient.getUngzippedContent(AndroidHttpClient.java:229) 12-17 15:28:53.630: E/Volley(22192): at com.salesforce.androidsdk.auth.HttpAccess$GzipDecompressingEntity.getContent(HttpAccess.java:447) 12-17 15:28:53.630: E/Volley(22192): at com.android.volley.toolbox.BasicNetwork.entityToBytes(BasicNetwork.java:215) 12-17 15:28:53.630: E/Volley(22192): at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.ja