You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by John Keyes <jo...@integralsource.com> on 2004/02/23 13:53:30 UTC
streaming request body
Hi,
I notice you have separated out the functions of the connection and the
content creation. So the code must be something like
HttpClient client = new HttpClient( url );
HttpMethod method = new GetMethod();
method.setRequestHeader( ... ); ...
method.setRequestBody( ... );
client.execute( method );
If I want to send a large attachment and I don't want it all to be in
memory then I can't do it. The issue is that you have to write your
data to the HttpMethod. The HttpMethod doesn't know where to then write
this data until you call execute and pass the client which has the
connection to write to. So there isn't really a way around this because
of the separation of the connection from the HttpMethod.
So my question is, is there a way to stream the request body rather
than having to store the request in memory prior to writing it on the
wire.
Thanks,
-John K
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
Re: streaming request body
Posted by Ortwin Glück <or...@nose.ch>.
John Keyes wrote:
> method.setRequestBody( ... );
> client.execute( method );
> So my question is, is there a way to stream the request body rather than
> having to store the request in memory prior to writing it on the wire.
setRequestBody accepts an InputStream. You could use a piped stream to
provide your data. Unfortunately HttpClient can not give you the
OutputStream of the underlying socket because of the connection pooling.
Please also note that an unbuffered request can not automatically be
retried.
HTH
Ortwin Glück
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org