tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sudeep Pradhan <pradh...@vmware.com>
Subject Comet: How to send *Chunked* response
Date Mon, 25 Jul 2011 18:23:28 GMT
Hi,

I am using CometProcessor to stream event notifications from server to client. The events
are generated at random.  I want to send the notification with Transfer Encoding as chunked
so that I can use Apache's ChunkedInputStream to parse the output.

I get the PrintWriter from the ServletResponse using the getWriter() and I write the event
notification on this writer. I want this to be in chunk format of length-payload. Currently
I do the following:

PrintWriter writer = connection.getWriter();
for (int j = 0; j < pendingEvents.length; j++) {
                                String eventString = converter.convert(pendingEvents[j]);
                                eventString.concat("\r\n");
                                final String length = Integer.toHexString(eventString.length());
                                writer.print("\r\n" + length + "\r\n");
                                writer.print(eventString);
                                //logger.info("Writing:" + eventString);
}

But this generates a Bad Chunk size exception on client.

Thanking you in anticipation.

Sudeep

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message