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

The following examples show how to use io.netty.handler.codec.http.HttpResponseStatus#FOUND . These examples are extracted from open source projects. 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 Project: ns4_frame   File: HttpResponse.java    License: Apache License 2.0 5 votes vote down vote up
private void writeResponseLocation(Channel channel, String URL) {
    // Decide whether to close the connection or not.
    boolean close = false;
    // Build the response object.
    FullHttpResponse response = new DefaultFullHttpResponse(
            HttpVersion.HTTP_1_1, HttpResponseStatus.FOUND);
    response.headers().set(CONTENT_TYPE, ContentType.HTML);
    response.headers().set(LOCATION, URL);
    response.headers().set(CONTENT_LENGTH, 0);
    // Write the response.
    ChannelFuture future = channel.writeAndFlush(response);
    future.addListener(ChannelFutureListener.CLOSE);
}
 
Example 2
@Override
public FullHttpResponse respond(FullHttpRequest req, ChannelHandlerContext ctx) throws Exception {
	doAction(req, ctx);
	DefaultFullHttpResponse res = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FOUND);
	res.headers().set(HttpHeaders.Names.LOCATION, redirectUri);
	return res;
}
 
Example 3
public void sendRedirect(ChannelHandlerContext ctx, String newUri) {
   FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FOUND);
   response.headers().set(HttpHeaders.Names.LOCATION, newUri);

   // Close the connection as soon as the error message is sent.
   ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
 
Example 4
Source Project: arcusplatform   File: AuthorizeHandler.java    License: Apache License 2.0 4 votes vote down vote up
private FullHttpResponse redirect(QueryStringEncoder encoder) {
   DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FOUND);
   response.headers().add(HttpHeaders.LOCATION, encoder.toString());
   return response;
}