LengthFieldBasedFrameDecoder variable length field problem.

Marc-André Laverdière marcandre.laverdiere at gmail.com
Wed Aug 3 08:50:48 EDT 2011


You can use both.

One decoder will split over the 200, the second one would convert the
text into a number and use that for decoding. It could also dismiss
the "OK Command completed successfully" afterwards and pass the
remaining stuff up the pipeline.

On 8/2/11, magneticB <tom.townsend at gmail.com> wrote:
> Hi,
>
> I'm decoding a simple text based protocol with Netty.  I issue text commands
> and an HTTP-like response including xml message comes back from the server,
> for example:
>
> 200 2769 OK Command completed successfully
> <?xml version="1.0" encoding="utf-8" ?>...
>
> On the first line 200 is the response code, it uses HTTP status codes, but
> doesn't conform to HTTP standard.  After that 2769 indicates the length of
> the message.  Clearly if the message is short this number will have a sorter
> length.  How can I use LengthFieldBasedFrameDecoder to cater for a length
> field that itself changes in length?  No padding around this field is used.
>
> Here's an example of a shorter response:
>
> 200 10 OK Command completed successfully
> <?xml vers
>
> Is LengthFieldBasedFrameDecoder the best approch for splitting a text based
> protocol?  Unfortunately no delimiter is appended to the end of the message
> or I would use DelimiterBasedFrameDecoder.
>
> Thanks for any help,
>
> Tom
>
> --
> View this message in context:
> http://netty-forums-and-mailing-lists.685743.n2.nabble.com/LengthFieldBasedFrameDecoder-variable-length-field-problem-tp6645775p6645775.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>


-- 
Marc-André LAVERDIÈRE
"Perseverance must finish its work so that you may be mature and complete,
not lacking anything." -James 1:4
http://asimplediscipleslife.blogspot.com/
mlaverd.theunixplace.com



More information about the netty-users mailing list