Im using netty3.3 version, I want to read the Body of the HTTP Request which i received. How it is posssible through NETTY 3.3.
Can any body help me.
In your SimpleChannelHandler
implemented class, override the messageReceived
method like following,
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
HttpRequest request = (HttpRequest) e.getMessage();
ChannelBuffer content = request.getContent();
LOGGER.info("Received Message[{}][{}]", request.getUri(), content.toString("UTF-8")); // Printing the URI and message body
}
content.toString("UTF-8")
will give the body.
Just use:
((HttpMessage) e.getMessage()).getContent();
See [1].
[1] http://netty.io/docs/stable/api/org/jboss/netty/handler/codec/http/HttpMessage.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.