Java Code Examples for io.netty.handler.codec.http.HttpResponseStatus#MOVED_PERMANENTLY

The following examples show how to use io.netty.handler.codec.http.HttpResponseStatus#MOVED_PERMANENTLY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NonSslRedirectHandler.java    From qonduit with Apache License 2.0 6 votes vote down vote up
@Override
protected ChannelHandler newNonSslHandler(ChannelHandlerContext context) {
    return new ChannelInboundHandlerAdapter() {

        private HttpResponseEncoder encoder = new HttpResponseEncoder();

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
            LOG.trace("Received non-SSL request, returning redirect");
            FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
                    HttpResponseStatus.MOVED_PERMANENTLY, Unpooled.EMPTY_BUFFER);
            response.headers().set(HttpHeaderNames.LOCATION, redirectAddress);
            LOG.trace(Constants.LOG_RETURNING_RESPONSE, response);
            encoder.write(ctx, response, ctx.voidPromise());
            ctx.flush();
        }
    };
}
 
Example 2
Source File: NonSslRedirectHandler.java    From timely with Apache License 2.0 6 votes vote down vote up
@Override
protected ChannelHandler newNonSslHandler(ChannelHandlerContext context) {
    return new ChannelInboundHandlerAdapter() {

        private HttpResponseEncoder encoder = new HttpResponseEncoder();

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
            LOG.trace("Received non-SSL request, returning redirect");
            FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
                    HttpResponseStatus.MOVED_PERMANENTLY, Unpooled.EMPTY_BUFFER);
            response.headers().set(HttpHeaderNames.LOCATION, redirectAddress);
            LOG.trace(Constants.LOG_RETURNING_RESPONSE, response);
            encoder.write(ctx, response, ctx.voidPromise());
            ctx.flush();
        }
    };
}
 
Example 3
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 4
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 5
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 6
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 7
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 8
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example 9
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
public static FullHttpResponse redirect(String url) {
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,HttpResponseStatus.MOVED_PERMANENTLY);
	response.headers().set(HEADER_LOCATION_NAME, url);	
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}