Android HttpResponse always dies the second time it's called

I have a weird crash when I cannot make the same network call twice.

HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); try { HttpResponse response = client.execute(post, new BasicHttpContext()); 

At the first start of a network call, it works fine, data is returned. The second time I start a network call (I have breakpoints here), it gets to the HttpResponse object, starts a network call, and then immediately jumps to an IOException catch.

the post object has the same data every time, all cookies are included.

I don't know anyone who knows about the server (drupal works), but this seems like a server problem.

Can someone shed light on why this will happen? Why will I be barred from receiving data a second time?

To shed light on things, if I break through the response object, I see that it can return "" instead of data. if it helps at all

 05-15 11:22:34.612: E/(1094): ObjectService 05-15 11:22:34.612: E/(1094): org.apache.http.client.ClientProtocolException 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557) 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 05-15 11:22:34.612: E/(1094): at com.fivepoints.service.ObjectService.getObject(ObjectService.java:121) 05-15 11:22:34.612: E/(1094): at com.fivepoints.model.team.TeamView$ActivityListTask.doInBackground(TeamView.java:94) 05-15 11:22:34.612: E/(1094): at com.fivepoints.model.team.TeamView$ActivityListTask.doInBackground(TeamView.java:1) 05-15 11:22:34.612: E/(1094): at android.os.AsyncTask$2.call(AsyncTask.java:185) 05-15 11:22:34.612: E/(1094): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) 05-15 11:22:34.612: E/(1094): at java.util.concurrent.FutureTask.run(FutureTask.java:138) 05-15 11:22:34.612: E/(1094): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) 05-15 11:22:34.612: E/(1094): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 05-15 11:22:34.612: E/(1094): at java.lang.Thread.run(Thread.java:1019) 05-15 11:22:34.612: E/(1094): Caused by: org.apache.http.client.CircularRedirectException: Circular redirect to 'http://mysite.com/demoObject/_c' 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:173) 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:903) 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:468) 05-15 11:22:34.612: E/(1094): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 05-15 11:22:34.612: E/(1094): ... 10 more 
+6
source share
1 answer

At first, the way I logged errors also caused a crash, so I did not know what the exact error was.

The real exception was Caused by: org.apache.http.client.CircularRedirectException , as the server handles API calls

This is a response from:

fooobar.com/questions/343928 / ...

HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);

0
source

Source: https://habr.com/ru/post/915807/


All Articles