java.net.ProtocolException: Too many redirects: 21 Android App

后端 未结 3 1702
梦毁少年i
梦毁少年i 2020-12-18 09:08

Hello i got the Problem that my app is so slow with this error:

java.net.ProtocolException: Too many redirects: 21

Now i dont know why it i

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-18 09:24

    Use HttpClient connection class

    org.apache.http.client.HttpClient
    

    instead of HttpURLConnection

    HttpClient httpClient = new DefaultHttpClient();
    httpClient.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); 
    HttpPost httpPost = new HttpPost("http:\\www.myweb.com"); 
    HttpResponse response = httpclient.execute(httppost); 
    responseBody = "";
    BufferedReader buffer = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    String s = "";
    while ((s = buffer.readLine()) != null) 
      responseBody += s;
    

提交回复
热议问题