hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dan evans <dev...@voxeo.com>
Subject Streaming with Chunks
Date Wed, 29 Jun 2011 18:33:53 GMT
In httpcore-4.1.1,

I'd like to take advantage of the line by line facility of SocketInputBuffer to read a continuous
stream of lines from a server as follows:

conn = new DefaultHttpClientConnection();
Socket socket = new Socket(host.getHostName(), host.getPort());
conn.bind(socket, params);
inbuffer = new SocketInputBuffer(socket, BUFSIZE, params);
lineBuf = new CharArrayBuffer(BUFSIZE);
while (streaming)
  if (inbuffer.readLine(lineBuf) < 0)
    streaming = false;

This works as long as the stream is not chunked.  But if the server sends a Transfer-encoding:
chunked stream, then the chunk metadata appears in the stream.  The CharArrayBuffer/SocketInputBuffer
API appears to be at a lower level than ChunkedInputStream.  Do I need to managed the (de)chunking
myself in this case, or have I missed the way to take advantage of ChunkedInputStream?


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

View raw message