--- snip ---
HttpResponse response = null;
InputStream in = null;
try {
client.execute(method);
} catch(Exception e) {
// handle exception
}
if(response.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = response.getEntity();
if(entity != null) {
try {
in = entity.getContent();
} catch(IOException e) {
// handle exception
}
}
}
if(in != null) {
// use in to read body of http response
}
--- snip ---
Maybe there is a better way to get the body from the response but I
don't know it...
Lutz Am 26.03.2009 um 15:43 schrieb zeeshan:
thanks for the reply, it is solved actually i was adding header before it get initialised it should be like this method = new HttpGet( new URI(url) ); method.addHeader("Connection","Keep-Alive"); i suppose to get an xml on this request , how can i make input stream? do i need to connect it again like below HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); InputStream in = httpConnection.getInputStream(); On Mar 26, 1:15 pm, Stoyan Damov <[email protected]> wrote:What happens if you do this instead:method.getParams().setParameter("http.useragent", this.user_agent_id);? On Thu, Mar 26, 2009 at 2:54 PM, zeeshan <[email protected]> wrote:Hi Experts,i am trying to add header on HttpGet but it raise this exception "InvocationTargetException"here is my code:DefaultHttpClient client = new DefaultHttpClient(); HttpGet method = null; HttpResponse resp = null;String url = "http://www.x.com/a.xml";method.addHeader("Connection","Keep-Alive"); /*method.addHeader("accept-language",this.accept_language); method.addHeader("user-agent-id",this.user_agent_id);*/method = new HttpGet( new URI(url) );i also used setHeader but same errorplease help me out--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature

