@Test public void testDefaultHttpConnIdleTimeout_RequestKeepAlive_ShouldHaveResponseKeepAlive() { HttpResponder responder = new HttpResponder(); ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); FullHttpRequest request = mock(FullHttpRequest.class); FullHttpResponse response = mock(FullHttpResponse.class); HttpHeaders headers = mock(HttpHeaders.class); Channel channel = mock(Channel.class); when(ctx.channel()).thenReturn(channel); when(request.content()).thenReturn(null); when(request.headers()).thenReturn(headers); when(headers.get(HttpHeaders.Names.CONNECTION)).thenReturn(HttpHeaders.Values.KEEP_ALIVE); when(request.getProtocolVersion()).thenReturn(HttpVersion.HTTP_1_1); HttpHeaders responseHeaders = new DefaultHttpHeaders(); when(response.headers()).thenReturn(responseHeaders); responder.respond(ctx, request, response); assertEquals("Connection: response header", HttpHeaders.Values.KEEP_ALIVE, responseHeaders.get(HttpHeaders.Names.CONNECTION)); }
public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); }
HttpResponder { public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); } }
HttpResponder { public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); } @VisibleForTesting  HttpResponder(); @VisibleForTesting  HttpResponder(int httpConnIdleTimeout); }
HttpResponder { public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); } @VisibleForTesting  HttpResponder(); @VisibleForTesting  HttpResponder(int httpConnIdleTimeout); static HttpResponder getInstance(); void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status); void respond(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res); }
HttpResponder { public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); } @VisibleForTesting  HttpResponder(); @VisibleForTesting  HttpResponder(int httpConnIdleTimeout); static HttpResponder getInstance(); void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status); void respond(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res);  }