您的帖子请求未能及时收到,请重试

时间:2013-07-13 09:44:41

标签: android httpclient

HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(
                    "http://xxxxxxx/geo/getlocation.php");

            MultipartEntity reqEntity = new MultipartEntity(
                    HttpMultipartMode.BROWSER_COMPATIBLE);

            reqEntity.addPart("longtiude", new StringBody(mylong));
            reqEntity.addPart("latitude", new StringBody(mylat));
            reqEntity.addPart("newtimeString", new StringBody(time));
            reqEntity.addPart("dateString", new StringBody(date));
            reqEntity.addPart("locationName", new StringBody(address));

            httppost.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(httppost);

            String responseBody = EntityUtils
                    .toString(response.getEntity());
            Log.e("response", responseBody);

我使用httpclient使用上面的代码在服务器上发布。但我得到了这样的反应

Your post request is not being received quickly enough please retry

我已正确添加权限和jar文件,也尝试使用basicnamevaluepair但响应相同。 httpclient已被弃用,但应该知道......

我不知道原因。我做错了什么。任何帮助请...

2 个答案:

答案 0 :(得分:1)

您尝试访问的服务器具有“缓慢的HTTP发布DDoS攻击”#39;已启用,拒绝您的请求。该规则通常有一些允许的时间来接收整个请求,如果没有,那么请求将被拒绝。

答案 1 :(得分:0)

这是我创建标签的方法:

public class MainActivity extends TabActivity {

TabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Resources res=getResources();
    tabHost=getTabHost();
    TabHost.TabSpec spec;
    Intent in;



    in=new Intent().setClass(this, Search.class);
    spec=tabHost.newTabSpec("Search").setIndicator("Search",res.getDrawable(R.drawable.ic_launcher)).setContent(in);
       tabHost.addTab(spec);



    in=new Intent().setClass(this, Search2.class);
    spec=tabHost.newTabSpec("Point").setIndicator("Point",res.getDrawable(R.drawable.ic_launcher)).setContent(in);
       tabHost.addTab(spec);


     in = new Intent().setClass(this, Search3.class);
       spec = tabHost.newTabSpec("social").setIndicator("Social",
                          res.getDrawable(R.drawable.ic_launcher))
                      .setContent(in);
      tabHost.addTab(spec);

        // Contact tabs
        in = new Intent().setClass(this, Search4.class);
        spec = tabHost.newTabSpec("contact").setIndicator("Contact",
                          res.getDrawable(R.drawable.ic_launcher))
                      .setContent(in);

        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);
}
}
相关问题