我目前正在开发一个android应用程序,提交一个post请求并处理相应的响应。
我可以将 post 请求发送到相应的 URL,但是当我尝试检索响应时,我得到了一半的 HTML 内容,后面跟着“ *Couldn't read CGI input from STDIN.AFTER ALLOC_READ 0* ”
谁能帮我解决这个问题。
这是代码片段
private void processRequest(String... params){
HttpPost post = new HttpPost("http://www.xyz.com");
HttpParams httpParams = post.getParams();
pnr = params[i];
httpParams.setParameter("param1", params[i]);
//User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1");
post.setParams(httpParams);
HttpClient client = new DefaultHttpClient();
try {
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
try {
processHtmlString(pnr, inputStreamToString(entity.getContent()).toString());
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
client.getConnectionManager().shutdown();
}
}
private String processHtmlString(String pnr, String htmlString) throws Exception{
int index = 0;
while(index < htmlString.length()){
int endIndex = (index + 3000) < (htmlString.length()) ? (index + 3000) : htmlString.length();
Log.i("HttpHelper1","HTML1 : "+htmlString.substring(index, endIndex));
index += 3000;
}
}
并且输出是............无法从 STDIN.AFTER ALLOC_READ 0 读取 CGI 输入