From 95b6ee80ca7a8a85c1c2ba95def9a3f603ef381f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 3 Jun 2014 09:21:03 +0200 Subject: [PATCH] OkResponseHandler should return a FullHttpResponse. Motivation: Currently OkResponseHandler returns a DefaultHttpResponse which is not correct and it should be returning complete http response. Modifications: Updated OkResponseHandler to return an instance of DefaultFullHttpResponse. Result: It is not possible to add compression to the example without getting any errors. --- .../java/io/netty/example/http/cors/OkResponseHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java b/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java index c2ab705372..33bd3b3f08 100644 --- a/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java +++ b/example/src/main/java/io/netty/example/http/cors/OkResponseHandler.java @@ -18,7 +18,8 @@ package io.netty.example.http.cors; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.DefaultHttpResponse; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; @@ -30,7 +31,7 @@ public class OkResponseHandler extends SimpleChannelInboundHandler { @Override public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { - final DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); + final FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); response.headers().set("custom-response-header", "Some value"); ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); }