handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg); handlerUtils.throwExceptionIfNotSuccessfullyDecoded(httpContentMsg); RequestInfo<?> requestInfo = state.getRequestInfo(); if (requestInfo == null) {
handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg); handlerUtils.throwExceptionIfNotSuccessfullyDecoded(httpContentMsg); RequestInfo<?> requestInfo = state.getRequestInfo(); if (requestInfo == null) {
handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg);
handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg);
@Override public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) { if (msg instanceof HttpRequest) { HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get(); RequestInfo request = handlerUtils.createRequestInfoFromNettyHttpRequestAndHandleStateSetupIfNecessary( (HttpRequest)msg, state ); // If the Netty HttpRequest is invalid, we shouldn't do any endpoint routing. handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg); // The HttpRequest is valid, so continue with the endpoint routing. Pair<Endpoint<?>, String> endpointForExecution = findSingleEndpointForExecution(request); request.setPathParamsBasedOnPathTemplate(endpointForExecution.getRight()); state.setEndpointForExecution(endpointForExecution.getLeft(), endpointForExecution.getRight()); throwExceptionIfContentLengthHeaderIsLargerThanConfiguredMaxRequestSize( (HttpRequest) msg, endpointForExecution.getLeft() ); } return PipelineContinuationBehavior.CONTINUE; }
@Override public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) { if (msg instanceof HttpRequest) { HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get(); RequestInfo request = handlerUtils.createRequestInfoFromNettyHttpRequestAndHandleStateSetupIfNecessary( (HttpRequest)msg, state ); // If the Netty HttpRequest is invalid, we shouldn't do any endpoint routing. handlerUtils.throwExceptionIfNotSuccessfullyDecoded((HttpRequest) msg); // The HttpRequest is valid, so continue with the endpoint routing. Pair<Endpoint<?>, String> endpointForExecution = findSingleEndpointForExecution(request); request.setPathParamsBasedOnPathTemplate(endpointForExecution.getRight()); state.setEndpointForExecution(endpointForExecution.getLeft(), endpointForExecution.getRight()); throwExceptionIfContentLengthHeaderIsLargerThanConfiguredMaxRequestSize( (HttpRequest) msg, endpointForExecution.getLeft() ); } return PipelineContinuationBehavior.CONTINUE; }
@DataProvider(value = { "true", "false" }) @Test public void throwExceptionIfNotSuccessfullyDecoded_works_as_expected( boolean decoderFailureExists ) { // given Throwable decoderFailureEx = new RuntimeException("intentional exception"); if (decoderFailureExists) { nettyRequest.setDecoderResult(DecoderResult.failure(decoderFailureEx)); } // when Throwable resultEx = catchThrowable(() -> implSpy.throwExceptionIfNotSuccessfullyDecoded(nettyRequest)); // then if (decoderFailureExists) { assertThat(resultEx) .isInstanceOf(InvalidHttpRequestException.class) .hasCause(decoderFailureEx); } else { assertThat(resultEx).isNull(); } }