tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Dumais" <>
Subject Comet position of CRLF in request chunks
Date Wed, 12 Dec 2007 13:33:18 GMT
I am using Comet for by directional communication between a native java
client and a tomcat server.

I noticed that when sending chunks to the Tomcat server over the request
stream Tomcat does not like to receive a CRLF at the end of a chunk, it
is only accepting the CRLF at the beginning of the following chunk.

According to rfc2616 the CRLF should be at the end of each chunk:

For example tomcat likes this type of chunk to be sent:
 CRLF chunk-size CRLF chunk-data

But it does not like this format:
 chunk-size CRLF chunk-data CRLF

Tomcat basically fires a Comet Read event to the CometProcessor with the
chunk data, but afterward fires an ERROR event with subevent type
IOEXCEPTION.  I have tested this with Tomcat 6.0.14 as well as the trunk
(Dec 11th, 2007).

Here is the sample code of a java client that connects to a simple
CometEcho processor:

Socket s = new Socket("localhost", 8080);
OutputStream out = s.getOutputStream();
out.write(("POST /CometEcho HTTP/1.1\r\n" +
	"Host: localhost:8080\r\n" +
      "Transfer-Encoding: chunked\r\n" +
boolean first = true;
BufferedReader reader = new BufferedReader(new

while (s.isConnected()) {
	String line = reader.readLine();
	//String chunk =
(first?"":"\r\n")+Integer.toHexString(line.length())+"\r\n"+line; //
tomcat only accepts this kind of chunk

	String chunk =
Integer.toHexString(line.length())+"\r\n"+line+"\r\n";   // this format
should work according to rfc2616

	first = false;

I was wondering if someone could explain this, and if this is by design,
or if I am using Comet incorrectly.

Thank you,

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message