protected static boolean fireStartEvent(ChannelHandlerContext ctx, HttpRequest request) { // Only allow this method to run once per request. Channel channel = ctx.channel(); Attribute<State> attr = channel.attr(ATTR_STATE); State state = attr.get(); if (state == State.STARTED) { // This could potentially happen if a bad client sends a 2nd request on the same connection // without waiting for the response from the first. And we don't support HTTP Pipelining. LOG.error("Received a http request on connection where we already have a request being processed. " + "Closing the connection now. channel = " + channel.id().asLongText()); channel.close(); ctx.pipeline().fireUserEventTriggered(new RejectedPipeliningEvent()); return false; } channel.attr(ATTR_STATE).set(State.STARTED); channel.attr(ATTR_HTTP_REQ).set(request); ctx.pipeline().fireUserEventTriggered(new StartEvent(request)); return true; }
protected static boolean fireStartEvent(ChannelHandlerContext ctx, HttpRequest request) { // Only allow this method to run once per request. Channel channel = ctx.channel(); Attribute<State> attr = channel.attr(ATTR_STATE); State state = attr.get(); if (state == State.STARTED) { // This could potentially happen if a bad client sends a 2nd request on the same connection // without waiting for the response from the first. And we don't support HTTP Pipelining. LOG.error("Received a http request on connection where we already have a request being processed. " + "Closing the connection now. channel = " + channel.id().asLongText()); channel.close(); ctx.pipeline().fireUserEventTriggered(new RejectedPipeliningEvent()); return false; } channel.attr(ATTR_STATE).set(State.STARTED); channel.attr(ATTR_HTTP_REQ).set(request); ctx.pipeline().fireUserEventTriggered(new StartEvent(request)); return true; }
protected static boolean fireStartEvent(ChannelHandlerContext ctx, HttpRequest request) { // Only allow this method to run once per request. Channel channel = ctx.channel(); Attribute<State> attr = channel.attr(ATTR_STATE); State state = attr.get(); if (state == State.STARTED) { // This could potentially happen if a bad client sends a 2nd request on the same connection // without waiting for the response from the first. And we don't support HTTP Pipelining. LOG.error("Received a http request on connection where we already have a request being processed. " + "Closing the connection now. channel = " + channel.id().asLongText()); channel.close(); ctx.pipeline().fireUserEventTriggered(new RejectedPipeliningEvent()); return false; } channel.attr(ATTR_STATE).set(State.STARTED); channel.attr(ATTR_HTTP_REQ).set(request); ctx.pipeline().fireUserEventTriggered(new StartEvent(request)); return true; }