I am using Http get and post methods for Http Connection I just wanted to ask that what all exception can occur in using them. I know list may be too long but can someone tell me the general and frequent exceptions that occur and must be handled? my code is :
public class httpconnection
{
HttpClient client=new DefaultHttpClient();
InputStream in=null;
public InputStream httpreponse_post(String url,List<NameValuePair> params)
{
try {
HttpPost post = new HttpPost(url);
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
in=resEntity.getContent();
in.close();
} catch (ClientProtocolException e)
{
Log. e ("Client Protocol Exception", e.toString ());
}
catch (IOException e) {
Log. e ("Input Output Exception", e.toString ());
}
return in;
}
public InputStream httpreponse_get(String url)
{
try
{
//String getURL = "http://www.google.com";
HttpGet get = new HttpGet(url);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
in=resEntityGet.getContent();
in.close();
}
catch (IOException e) {
Log. e ("Input Output Exception", e.toString ());
}
return in;
}
}