从服务器下载图像时出错
我从 logcat 收到此错误
org.apache.http.NoHttpResponseException:目标服务器响应失败。
可能是什么原因?
我的下载代码如下。
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse)httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
bmImg = BitmapFactory.decodeStream(instream);
I am getting this error from the logcat
org.apache.http.NoHttpResponseException: The target server failed to respond.
What might be the reason?
My download code is as below.
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse)httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
bmImg = BitmapFactory.decodeStream(instream);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调用以下方法并传入 URL 。
public Bitmap DownloadFromUrl(String imageURL) { //这是下载器方法
call following methods and pass in URL .
public Bitmap DownloadFromUrl(String imageURL) { //this is the downloader method
NoHttpResponseException
意味着一件事,也是唯一的一件事:服务器在没有发回 HTTP 响应消息的情况下关闭了连接,很可能是由于在处理请求期间遇到异常情况。换句话说,这很可能是服务器端错误。NoHttpResponseException
means one and only thing: the server closed connection without sending back an HTTP response message, most likely due to an abnormal condition encountered during processing of the request. In other words, this is most likely a server side bug.