commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ortwin Glück" <ortwin.glu...@nose.ch>
Subject Re: [HttpClient] Retriving an unbuffered stream
Date Fri, 23 Aug 2002 08:15:40 GMT
To achieve this we clearly need to change the way HttpMethods handle the 
response stream. Currently it is read entirely, even though this is 
completely unnecessary.

The following needs to be done:

1. Refactor ResponseInputStream. Even a chunked response should not be 
buffered partially. Add more state information to keep track where in 
the chunked stream we are and just return the appropriate data on a read 
without using buffers.
A separate ChunkedInputStream class would be a great help in separating 
functionality. (I have such a class ready and can contribute it if 
needed.) So ResponseInputStream only has to decide if to wrap the 
InputStream from the socket into this ChunkedInputStream or forward the 
  data directly.

2. Change HttpMethodBase.responseBody to be of type InputStream. If we 
need the data as String we can always read it in completely (I don't 
favor this idea and consider this the responsibility of the application 
and not the HttpClient. Deliviring a InputStream is all we need). Same 
applies to buffering in a disk file. This also reduces array copy 
operations.
(The all-over strategy of any protocol should be to use as little copy 
operations as possible anyway. This is a common problem with ultra high 
bandwiths and certain IP stacks for example.)

awaiting your comments.

Odi

Jeff Dever wrote:
> Hmmmm,
> 
> I don't see any way to get an unbuffered output stream.  There is a public
> ResponseInputStream class in HttpClient that handles chunking and such but I
> don't see any reasonable way of getting at it from a HttpMethod.  Even if
> you could access it, the response would have already been buffered in a
> byte[] after the execute() method is called.
> 
> As Mark noted, the getResponseBodyAsStream() is not particularly useful and
> only saves the caller from doing a stream = new
> ByteArrayInputStream(method.getResponseBody()).
> 
> Anyone have any ideas on this?

-- 
_________________________________________________________________
  NOSE applied intelligence ag      [perspectix-nose digital b.i]
                                    [www]      http://www.nose.ch
  ortwin glück                      [email] ortwin.glueck@nose.ch
  hardturmstrasse 171               [office]      +41-1-277 57 35
  8005 zurich                       [fax]         +41-1-277 57 12
  switzerland



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


Mime
View raw message