Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting an object into a ChannelBuffer
    primarykey
    data
    text
    <p>I've written a small http server using Netty by following the <a href="http://static.netty.io/3.5/xref/org/jboss/netty/example/http/file/package-summary.html" rel="nofollow">example http server</a> and now i'm trying to adapt it to my needs (a small app that should send json). I began by manually encoding my POJOs to json using jackson and then using the StringEncoder to get a ChannelBuffer. Now i'm trying to generalize it slightly by extracting the bit that encodes the POJOs to json by adding a <a href="http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpContentEncoder.html" rel="nofollow">HttpContentEncoder</a> and I've managed to implement that more or less.</p> <p>The part that i can't figure out is how to set the content on the <a href="http://static.netty.io/3.5/api/org/jboss/netty/handler/codec/http/HttpResponse.html" rel="nofollow">HttpResponse</a>. It expects a ChannelBuffer but how do i get my object into a ChannelBuffer?</p> <p><strong>Edit</strong></p> <p>Say i have a handler with code like below and have a HttpContentEncoder that knows how to serialize SomeSerializableObject. Then how do i get my content (SomeSerializableObject) to the HttpContentEncoder? That's what i'm looking for.</p> <pre><code>SomeSerializableObject obj = ... // This won't work becuase the HttpMessage expects a ChannelBuffer HttpRequest res = ... res.setContent(obj); Channel ch = ... ch.write(res); </code></pre> <p>After looking into it a bit more though i'm unsure if this is what HttpContentEncoder is meant to do or rather do stuff like compression?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload