2013-07-13 61 views
2
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弃用,但它应该知道...

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

回答

1

您试图命中的服务器已启用'缓慢HTTP发布DDoS攻击',这是拒绝您的请求。该规则通常有一些允许的时间来接收整个请求,如果没有,则请求将被拒绝。

+0

感谢如何解决这个问题。任何可能在服务器上更改的设置 – Senthil

+0

@vsk取决于用于处理这些攻击的设备。例如,对于F5,这里是一个链接:https://devcentral.f5.com/tech-tips/articles/mitigating -slow-HTTP-POST-DDOS攻击与 - 的iRules#.UeEi4vk3CAg –

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); 
} 
}