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)
{
lineBuf.clear();
if (inbuffer.readLine(lineBuf) < 0)
{
streaming = false;
continue;
}
System.out.println(lineBuf.toString());
}
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?
Dan
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]