[BinaryRequestInfo]no body data

May 4, 2014 at 2:04 PM
Hi, all
 I send Binary data from android to server, but the server only receive the head data, the body data is empty. That's why?Thank you!
The code like this:
Server:
public class BinnaryReceiveFilter : FixedHeaderReceiveFilter<BinaryRequestInfo>
{
    public BinnaryReceiveFilter()
        : base(17)
    {

    }

    protected override int GetBodyLengthFromHeader(byte[] header, int offset, int length)
    {
        return (int)header[offset + 15] * 256 + (int)header[offset + 16];
    }

    protected override BinaryRequestInfo ResolveRequestInfo(ArraySegment<byte> header, byte[] bodyBuffer, int offset, int length)
    {
        return new BinaryRequestInfo(Encoding.UTF8.GetString(header.Array, header.Offset, 15), bodyBuffer.CloneRange(offset, length));
    }
}
The Client:
OutputStream outputStream = client.getOutputStream();
byte[] b = commandName.getBytes("UTF-8");
byte[] b1 = new byte[] { (byte)(file.length / 256), (byte)(file.length % 256) };
outputStream.write(b);
outputStream.write(b1);
outputStream.write(file);
outputStream.flush();
Coordinator
May 4, 2014 at 2:27 PM
What's your header size?

Could you confirm if the body length you return is correct?
May 4, 2014 at 2:36 PM
Header size is 17. I find header parameter in GetBodyLengthFromHeader and bodyBuffer parameter in ResolveRequestInfo method is all 0.
Coordinator
May 4, 2014 at 2:40 PM
NO, you should read data from header from offset instead of 0.
May 4, 2014 at 3:06 PM
OK, I will try again!
Thank you!
May 5, 2014 at 5:03 AM
I find the error is byte is 0 -127 in java, so the body length is 0.
It's ok now, I change the java code.
Thank you!