Reputation: 3095
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);
Upvotes: 0
Views: 478
Reputation: 27538
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.
Upvotes: 1
Reputation: 333
call following methods and pass in URL .
public Bitmap DownloadFromUrl(String imageURL) { //this is the downloader method
Bitmap bm=null;
try {
URL url = new URL(imageURL); //you can write here any link
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
}
bm= BitmapFactory.decodeByteArray(baf.toByteArray(), 0, baf.toByteArray().length);
} catch (IOException e) {
Log.d("ImageManager", "Error: " + e);
}
return bm;
}
Upvotes: 1