hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zarian <rianlapi...@gmail.com>
Subject HTTPResponse
Date Fri, 05 Jun 2009 06:20:24 GMT

Hope somebody can help me...

I got the HTTP response and able to retrieve the corresponding headers, but
the problem is the response comes with message body which is in xml
format... can someone help me provide the necessary code for to retrieve the
message body...

thanks... 


heres my code...


DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(responseURL);
        Credentials defaultcreds = new UsernamePasswordCredentials(USERNAME,
PASSWORD);
        client.getCredentialsProvider().setCredentials(new
AuthScope(DEVSERVER, PORT, REALM), defaultcreds);
      
        System.out.println("Retrieving... ");
        try {

            HttpResponse convertedResponse = client.execute(httpget);
           
            System.out.println("Connection: " +
convertedResponse.getHeaders("Connection")[0].getValue().trim());
            System.out.println("Date: " +
convertedResponse.getHeaders("Date")[0].getValue().trim());
            System.out.println("Content-type: " +
convertedResponse.getHeaders("Content-type")[0].getValue().trim());
            System.out.println("Content-Length: " +
convertedResponse.getHeaders("Content-Length")[0].getValue().trim());
            
        } catch (Exception ex) {
            ex.printStackTrace(pw);
        }
-- 
View this message in context: http://www.nabble.com/HTTPResponse-tp23881232p23881232.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message