尝试从Android应用程序向服务器发送文件内容,如下所示:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
final InputStreamEntity reqEntity = new InputStreamEntity(
gdFileSystemDelegate.openFileInput(openFileInput(FilePath), -1);
reqEntity.setContentType("application/octet-stream");
httppost.setEntity(reqEntity);
httpClient.execute(httppost);
但它引发了一个例外: 无法使用不可重复的请求实体重试请求
这是什么意思?如何解决这个问题?
答案 0 :(得分:-1)
尝试在DefaultHttpClient中将协议参数http.protocol.expect-continue设置为true:
@Override
protected HttpParams createHttpParams() {
HttpParams params = super.createHttpParams();
HttpProtocolParams.setUseExpectContinue(params, true);
return params;
}