hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpClient and streaming xml out
Date Wed, 07 Jul 2004 21:54:53 GMT
Tim,

HttpClient 2.0 supports a reverse model compared to HttpURLConnection.
Instead of providing you with an output stream it can read the request
body directly from an input stream and write it to the socket output
stream for you

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/PostXML.java?rev=1.10.2.1&only_with_tag=HTTPCLIENT_2_0_BRANCH&view=markup

HttpClient 3.0 can do both with a little help from your side, which
would basically require you to provide a class implementing
RequestEntity interface

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/PostXML.java?only_with_tag=HTTPCLIENT_2_0_BRANCH&view=markup

Oleg

On Wed, 2004-07-07 at 23:10, Tim Wild wrote:
> Hi all,
> 
> We have the need to connect to a server and authenticate using client 
> certificates, then stream an xml request out to it. I can do the client 
> cert stuff, but can streaming out the xml be done with HttpClient? Our 
> current code (without client cert support) is below.
> 
> The other method i've tried is just using a plain HttpsUrlConnection, 
> but getting it to send the client cert is proving to be tricky. I've 
> registered the DefaultSSLSocketFactory, but for some reason it won't 
> present my client cert :(
> 
> Any thoughts appreciated.
> 
> Thanks
> 
> Tim
> 
> URL urlObj = new URL(url);
> HttpURLConnection.setFollowRedirects(true);
> HttpURLConnection connection = (HttpURLConnection)urlObj.openConnection();
> connection.setRequestMethod("POST");
> connection.setDoInput(true);
> connection.setDoOutput(true);
> connection.setInstanceFollowRedirects(true);
> OutputStream os = connection.getOutputStream();
> PrintWriter writer = new PrintWriter(os, true);
> writer.println(message);
> os.close();
> InputStream is = connection.getInputStream();
> Reader reader = Util.convertInputStreamToReader(is);
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message