A question about ReplayingDecoder

Trustin Lee tlee at redhat.com
Wed Apr 8 06:09:30 EDT 2009


On Wed, Apr 8, 2009 at 7:04 PM, Nicholas Clare <nickclare at gmail.com> wrote:
> Hi,
>
> I did check out the trunk, and it has indeed fixed the problem.
> However, as per your advice, I'm currently rewriting my decoder to use
> your method to read lines. I do have another question. The STOMP
> protocol spec is pretty vague, and I'm not all that experienced with
> it. In your HTTP code, it seems like you're assuming the headers are
> ACSII text, since you're casting single bytes to chars. Obviously that
> assumption is fine with HTTP, I'm not trying to suggest your code is
> wrong.
>
> In STOMP, however, they don't say anything like that anywhere, so I
> figure it would be safer to try for UTF-8. So, where you put each
> character into a StringBuilder, I'm using a ChannelBuffer (built by
> ChannelBuffers.dynamicBuffer()), and only decoding the string at the
> end (using ChannelBuffer.toString("UTF-8")). Does this seem like a
> reasonable way to accomplish this?

Yes.  Also, you could just remember the start index and the length of
the string and call ChannelBuffer.toString(int, int, "UTF-8") for
efficiency.

HTH,

— Trustin Lee, http://gleamynode.net/




More information about the netty-users mailing list