StaticFileServerHandler.setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
/** * Sends the given error response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param errorMessage which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static CompletableFuture<Void> sendErrorResponse( ChannelHandlerContext channelHandlerContext, HttpRequest httpRequest, ErrorResponseBody errorMessage, HttpResponseStatus statusCode, Map<String, String> headers) { return sendErrorResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), errorMessage, statusCode, headers); }
/** * Sends the given response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param message which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static void sendResponse( @Nonnull ChannelHandlerContext channelHandlerContext, @Nonnull HttpRequest httpRequest, @Nonnull String message, @Nonnull HttpResponseStatus statusCode, @Nonnull Map<String, String> headers) { sendResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), message, statusCode, headers); }
/** * Sends the given response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param message which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static CompletableFuture<Void> sendResponse( @Nonnull ChannelHandlerContext channelHandlerContext, @Nonnull HttpRequest httpRequest, @Nonnull String message, @Nonnull HttpResponseStatus statusCode, @Nonnull Map<String, String> headers) { return sendResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), message, statusCode, headers); }
/** * Sends the given error response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param errorMessage which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static void sendErrorResponse( ChannelHandlerContext channelHandlerContext, HttpRequest httpRequest, ErrorResponseBody errorMessage, HttpResponseStatus statusCode, Map<String, String> headers) { sendErrorResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), errorMessage, statusCode, headers); }
/** * Sends the given error response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param errorMessage which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static CompletableFuture<Void> sendErrorResponse( ChannelHandlerContext channelHandlerContext, HttpRequest httpRequest, ErrorResponseBody errorMessage, HttpResponseStatus statusCode, Map<String, String> headers) { return sendErrorResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), errorMessage, statusCode, headers); }
/** * Sends the given response and status code to the given channel. * * @param channelHandlerContext identifying the open channel * @param httpRequest originating http request * @param message which should be sent * @param statusCode of the message to send * @param headers additional header values */ public static CompletableFuture<Void> sendResponse( @Nonnull ChannelHandlerContext channelHandlerContext, @Nonnull HttpRequest httpRequest, @Nonnull String message, @Nonnull HttpResponseStatus statusCode, @Nonnull Map<String, String> headers) { return sendResponse( channelHandlerContext, HttpHeaders.isKeepAlive(httpRequest), message, statusCode, headers); }
public static ChannelFuture flush(Channel ch, HttpRequest req, HttpResponse res) { if (!HttpHeaders.isKeepAlive(req)) { return ch.writeAndFlush(res).addListener(ChannelFutureListener.CLOSE); } else { res.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE); return ch.writeAndFlush(res); } } }
public static ChannelFuture flush(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) { if (!HttpHeaders.isKeepAlive(request)) { return ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE); return ctx.writeAndFlush(response); } }
public static ChannelFuture flush(Channel ch, HttpRequest req, HttpResponse res) { if (!HttpHeaders.isKeepAlive(req)) { return ch.writeAndFlush(res).addListener(ChannelFutureListener.CLOSE); } else { res.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE); return ch.writeAndFlush(res); } } }
public static ChannelFuture flush(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) { if (!HttpHeaders.isKeepAlive(request)) { return ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE); return ctx.writeAndFlush(response); } }
setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
StaticFileServerHandler.setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
StaticFileServerHandler.setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
setDateAndCacheHeaders(response, file); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
private void display(ChannelHandlerContext ctx, HttpRequest request, String message) { HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK); response.headers().set(CONTENT_TYPE, "text/plain"); if (HttpHeaders.isKeepAlive(request)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); } byte[] buf = message.getBytes(ConfigConstants.DEFAULT_CHARSET); ByteBuf b = Unpooled.copiedBuffer(buf); HttpHeaders.setContentLength(response, buf.length); // write the initial line and the header. ctx.write(response); ctx.write(b); ChannelFuture lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT); // close the connection, if no keep-alive is needed if (!HttpHeaders.isKeepAlive(request)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE); } } }
response.headers().set(CONTENT_TYPE, "text/plain"); if (HttpHeaders.isKeepAlive(httpRequest)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(httpRequest)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
response.headers().set(CONTENT_TYPE, "text/plain"); if (HttpHeaders.isKeepAlive(httpRequest)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(httpRequest)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);
response.headers().set(CONTENT_TYPE, "text/plain"); if (HttpHeaders.isKeepAlive(httpRequest)) { response.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); if (!HttpHeaders.isKeepAlive(httpRequest)) { lastContentFuture.addListener(ChannelFutureListener.CLOSE);