HTTP Post received at Servlet contains CRLF

Hi, I have a midlet which send data via HTTP POST to a servlet. The data is written from a byte array via:

connector = (HttpConnection)Connector.open(aHostURL, Connector.READ_WRITE,true);

connector.setRequestMethod(HttpConnection.POST);

connector.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");

connector.setRequestProperty("Content-Language","en-CA");

connector.setRequestProperty("Content-length",Integer.toString(this.length()));

connector.setRequestProperty("Content-Type","application/binary");

connector.setRequestProperty("Accept","application/octet-stream" );

connector.setRequestProperty("Connection","close" );

outStream = connector.openOutputStream();

outStream.write(byteArray);

outStream.flush();

and then the data is read from a servlet via:

ServletInputStream sin = request.getInputStream();

byte[] data =newbyte[80];

int amountRead = sin.read(data, 0, data.length);

while (amountRead > 0){

for (int i=0; i<amountRead; i++){

System.out.print(data[i]);

}

totalAmountRead = totalAmountRead + amountRead;

amountRead = sin.read(data, 0, data.length);

}

Here is the data sent:

999999999999999999999999999999

and the data received:

491011310999999999999999999999

The frustrating thing is that at the beginning of the data read (from the servlet), there is a "491011310" (the "1310" being a crlf) before any of my data. I have researched the newsgoups, and tried various different parameters with no luck. It appears to be part of HTTP, but this should not be appearing in the POST data. Can someone give me some ideas to try out?

thanks

Don

>

[2495 byte] By [d1camero] at [2007-9-26 14:29:31]
# 1
is the same number "491011310" always added?if so can't you just chop it off at the receiving end?
lnoelstorr at 2007-7-2 16:16:09 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
No, it is a different number with varying data. I would rather know why it is being added and make the appropriate configuration changes to protocol than simply remove the number. I suspect it is part of the HTTP protocol, as the protocol uses CRLF as a delimeter.
d1camero at 2007-7-2 16:16:09 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

If you think it could be a HTTP protocol issue then maybe you would be better asking on a Servlet or JSP forum or something. People on there are more likely to have experienced something similar.

Also, have you tried similar code in a non-midlet java program? If it does the same from other java code then it would seem to be something to do with the http protocol, if not then it would seem that it is related to the midlet.

lnoelstorr at 2007-7-2 16:16:09 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
The problem is that I am using Tomcat 3.2 and HTTP 1.1. I upgraded to Tomcat 4.0 and all works well. Good thing I do not rely on this forum to help me with my problems...
d1camero at 2007-7-2 16:16:09 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
Yes it is indeed a good job you don't rely on a J2ME forum to help you solve your problems with Tomcat ;-)
lnoelstorr at 2007-7-2 16:16:09 > top of Java-index,Java Mobility Forums,Java ME Technologies...