2015-07-05 85 views
0

LengthFieldBasedFrameDecoder的文檔中,它允許用戶解碼標題字段Header 1。那麼哪個編碼器類允許用戶定義這樣的標題字段?如何設置LengthFieldBasedFrameDecoder類中提到的長度調整字節

* This is an advanced example that shows the case where there is an extra 
* header between the length field and the message body. You have to specify a 
* positive <tt>lengthAdjustment</tt> so that the decoder counts the extra 
* header into the frame length calculation. 
* <pre> 
* lengthFieldOffset = 0 
* lengthFieldLength = 3 
* <b>lengthAdjustment</b> = <b>2</b> (= the length of Header 1) 
* initialBytesToStrip = 0 
* 
* BEFORE DECODE (17 bytes)      AFTER DECODE (17 bytes) 
* +----------+----------+----------------+  +----------+----------+----------------+ 
* | Length | Header 1 | Actual Content |----->| Length | Header 1 | Actual Content | 
* | 0x00000C | 0xCAFE | "HELLO, WORLD" |  | 0x00000C | 0xCAFE | "HELLO, WORLD" | 
* +----------+----------+----------------+  +----------+----------+----------------+ 

回答

0

Netty的本身不包含這種編碼器,但你應該能夠輕鬆地編寫自己的,只是寫字節到ByteBuf你把它寫下來的管道之前。

相關問題