Bug 54628 - there is something wrong when send binary data by websocket.
there is something wrong when send binary data by websocket.
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.37
PC Linux
: P2 major (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-03-02 08:37 UTC by blee
Modified: 2013-03-06 20:55 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description blee 2013-03-02 08:37:25 UTC
there is something wrong when send binary data by websocket.

see org.apache.catalina.websocket.WsOutbound.doWriteBytes(ByteBuffer, boolean)

I think 

// Write the content
        upgradeOutbound.write(buffer.array(), 0, buffer.limit());
        upgradeOutbound.flush();

should change to :

// Write the content
        upgradeOutbound.write(buffer.array(), buffer.arrayOffset(), buffer.limit());
        upgradeOutbound.flush();


For example:
byte[] bts = new byte[]{1,2,3,4,5}
ByteBuffer bf = ByteBuffer.wrap(bts, 2, 2);
out.writeBinaryMessage(bf);

I mean write [3,4] to the client, but in fact [1,2,3,4] be sent;
Comment 1 Mark Thomas 2013-03-06 20:55:17 UTC
Thanks for the report and for the fix.

This has been fixed in trunk and 7.0.x and will be included in 7.0.38 onwards.