Feature Request - Add Charset Validation (Without Copy) To ChannelBuffer API?

33 views
Skip to first unread message

Gareth Collins

unread,
Nov 17, 2011, 11:58:27 AM11/17/11
to ne...@googlegroups.com
Hello,

Would it sound reasonable if a ChannelBuffer could verify a Charset without a copy?

Here is my use case:

In implementing Web Sockets one thing that a valid client needs to do is verify that
incoming messages are encoded in UTF-8 (and return an error to the server if it is not).
The current method of verifying a Charset is valid UTF-8 is by converting the
ChannelBuffer to a string.

If the text message is very large, this would mean keeping two copies of the message
in memory simultaneously. If the ChannelBuffer could be validated as UTF-8 without a copy,
I could just wrap in a ChannelBufferInputStream and provide to the Web Sockets API
client (as an Input Stream). The Web Sockets API client could then decide whether
to copy, send to a file or perhaps use the input stream for a SAX parser.

So would this be a reasonable future feature? I thought this could fit as I understood one of the
primary goals of the ChannelBuffer API is to minimize memory copies.

thanks,
Gareth

"이희승 (Trustin Lee)"

unread,
Nov 17, 2011, 3:42:07 PM11/17/11
to ne...@googlegroups.com
Sounds like a good idea. Could you file an issue in our issue tracker?

Cheers

Trustin Lee, http://gleamynode.net/

Reply all
Reply to author
Forward
0 new messages