android http重复请求,android – HttpPost由于“无法重试请求与不可重复的请求实体”失败...

我试图通过HttpClient在

Android手机中将照片上传到服务器,但有时我会收到这个错误,它不会总是发生.有谁知道如何解决呢?

我的代码如下:

HttpClient client =new DefaultHttpClient();

HttpPut httpPut = new HttpPut(uploadUrl);

InputStream in =null;

HttpResponse response =null;

try {

in = new FileInputStream(filepath);

BasicHttpEntity entity = new BasicHttpEntity();

entity.setContent(in);

entity.setContentLength(new File(basepath+path).length());

httpPut.setEntity(entity);

response = client.execute(httpPut);

System.out.println(response.getStatusLine());

consume(response.getEntity());

}

…….

错误信息:

11-22 10:32:50.370: W/System.err(15224): org.apache.http.client.ClientProtocolException

11-22 10:32:50.370: W/System.err(15224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)

11-22 10:32:50.370: W/System.err(15224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)

11-22 10:32:50.370: W/System.err(15224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)

11-22 10:32:50.370: W/System.err(15224): at com.hp.nimbus.android.skydrive.util.SkyDriveUtils_Rest.doUploadPhoto(SkyDriveUtils_Rest.java:203)

11-22 10:32:50.380: W/System.err(15224): at com.hp.nimbus.android.skydrive.util.SkyDriveUtils_Rest.uploadPhoto(SkyDriveUtils_Rest.java:250)

11-22 10:32:50.380: W/System.err(15224): at com.hp.nimbus.android.skydrive.FolderMonitorService$1.onEvent(FolderMonitorService.java:36)

11-22 10:32:50.380: W/System.err(15224): at android.os.FileObserver$ObserverThread.onEvent(FileObserver.java:125)

11-22 10:32:50.380: W/System.err(15224): at android.os.FileObserver$ObserverThread.observe(Native Method)

11-22 10:32:50.380: W/System.err(15224): at android.os.FileObserver$ObserverThread.run(FileObserver.java:88)

11-22 10:32:50.380: W/System.err(15224): Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity

11-22 10:32:50.380: W/System.err(15224): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:419)

11-22 10:32:50.380: W/System.err(15224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)

11-22 10:32:50.390: W/System.err(15224): ... 8 more

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值