小编gan*_*esh的帖子

为什么我得到 Android : The target server failed to response?

API链接: http://www.familybuds.com/storegrunt-new/api_home/validate_step_one/platform/1

POST 参数:store_name = "abc"代码在 GoDaddy 服务器上

这个 api 一直工作到 7 月 25 日,但突然从 26 号早上开始在 Android APP 上停止工作。相同的 api 在 iPhone APP 上运行良好。

安卓代码:

HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
HttpConnectionParams.setSoTimeout(httpParameters, 10000+12000);

DefaultHttpClient  client = new DefaultHttpClient(httpParameters);
HttpPost httppost = new HttpPost(url);

HttpResponse response; 
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  

client.addRequestInterceptor(new HttpRequestInterceptor() {              

        @Override
        public void process(HttpRequest request, HttpContext context)
                throws HttpException, IOException {
            // TODO Auto-generated method stub
            if (!request.containsHeader("Accept-Encoding")) {
                request.addHeader("Accept-Encoding", "gzip");
            }
        }

    });

client.addResponseInterceptor(new HttpResponseInterceptor() …
Run Code Online (Sandbox Code Playgroud)

api android http httpresponse

3
推荐指数
1
解决办法
8916
查看次数

标签 统计

android ×1

api ×1

http ×1

httpresponse ×1