【发布时间】:2011-11-16 04:36:17
【问题描述】:
只是一些入门信息。我正在编写一个使用 MVC 平台与用 C#.Net 编写的服务器对话的 Andorid 应用程序。每个请求都是一个帖子,ActionFilter 属性确保了这一点。但是由于这个问题,.Net 将 HttpMethod 解析为“ST”。
以下是我在全局范围内用于从我的应用程序发出 Web 请求的代码:
private String MakeRequest(String action, String params){
try {
HttpPost request = new HttpPost(mProtocol + mSubDomain + mHost + action);
String args;
if (params != null) {
args = params;
} else {
args = "[]";
}
StringEntity requestEntity;
requestEntity = new StringEntity(args);
requestEntity.setContentType("application/json;charset=UTF-8");
requestEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json;charset=UTF-8"));
request.setEntity(requestEntity);
HttpResponse response = mHttpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
String jString = EntityUtils.toString(responseEntity);
return jString;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
我只有一种特定方法存在这个问题,所有其他方法都可以正常工作。
以下链接指向包含流量的 pcap 文件,因此它是清晰可见的。 (我已将其过滤到仅适用的行) http://dl.dropbox.com/u/315661/defect.pcap
【问题讨论】:
-
另外值得一提的是,我已经看到它在 20-30 次尝试中运行一次。有一次它成功了,请求是一个数据包。
标签: java android asp.net-mvc http-post