hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ajay Bansal" <ajay.bansa...@gmail.com>
Subject help with httppost response
Date Wed, 13 Jan 2010 10:56:08 GMT
Hi All,

I am using 4x APIs. Here is my code

=========================

		String baseServer = "http://localhost:8080";

		String serverUrl = baseServer + Some API URL;
		String signature = genSig.getSignature();

		HttpClient httpclient = new DefaultHttpClient();

		HttpPost httppost = new HttpPost(serverUrl);
		httppost.setHeader(Sets the header);

		File file = new File("data/userRegister.xml");

		InputStreamEntity reqEntity = new InputStreamEntity(
				new FileInputStream(file), -1);
		reqEntity.setContentType("application/xml");
		reqEntity.setChunked(true);

		httppost.setEntity(reqEntity);

		System.out.println("executing request " +
httppost.getRequestLine());
		HttpResponse response = httpclient.execute(httppost); /*
THIS CODE WORKS FINE - I see the REQUEST in the backend */

/* Problem is I am not able to capture the response using following code.
What do I need to do? */


		HttpEntity resEntity = response.getEntity();

		
		System.out.println("Status : " + response.getStatusLine());
		
		if (resEntity != null) {
			System.out.println("Response content length: "
					+ resEntity.getContentLength());
/* I always get this as -1*/
			System.out.println("Chunked?: " +
resEntity.isChunked());
		}

		if (resEntity != null) {
			resEntity.consumeContent();
		}
    
===============================

I need to print the response that I get from the above method. How do I do
that?

Regards
Ajay




---------------------------------------------------------------------
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