Source:
<code>private boolean handleRequest(HttpRequest httpRequest) throws RestServiceException { boolean success = true; if (responseChannel == null || requestContentFullyReceived) { long processingStartTime = System.currentTimeMillis(); resetState(); nettyMetrics.requestArrivalRate.mark(); if (!httpRequest.decoderResult().isSuccess()) { success = false; logger.warn("Decoder failed because of malformed request on channel {}", ctx.channel(), httpRequest.decoderResult().cause()); nettyMetrics.malformedRequestError.inc(); onRequestAborted(new RestServiceException("Decoder failed because of malformed request", RestServiceErrorCode.MalformedRequest)); } else { try { if ((HttpMethod.POST.equals(httpRequest.method()) || HttpMethod.PUT.equals(httpRequest.method())) && HttpPostRequestDecoder.isMultipart(httpRequest)) { nettyMetrics.multipartPostRequestRate.mark(); request = new NettyMultipartRequest(httpRequest, ctx.channel(), nettyMetrics, nettyConfig.nettyBlacklistedQueryParams, nettyConfig.nettyMultipartPostMaxSizeBytes); } else { request = new NettyRequest(httpRequest, ctx.channel(), nettyMetrics, nettyConfig.nettyBlacklistedQueryParams); } responseChannel.setRequest(request); logger.trace("Channel now handling request {}", ctx.channel(), request.getUri()); <START> if ((request.getRestMethod().equals(RestMethod.POST) || request.getRestMethod().equals(RestMethod.PUT)) <END> && !HttpPostRequestDecoder.isMultipart(httpRequest) && !request.isHttp2RequestFromFrontend()) { requestHandler.handleRequest(request, responseChannel); } } catch (RestServiceException e) { success = false; onRequestAborted(e); } finally { if (request != null) { request.getMetricsTracker().nioMetricsTracker.addToRequestProcessingTime( System.currentTimeMillis() - processingStartTime); } } } } else { success = false; logger.error("New request received when previous request is yet to be fully received on channel {}. Request under" + " processing: {}. Unexpected request: {}", ctx.channel(), request.getUri(), httpRequest.uri()); nettyMetrics.duplicateRequestError.inc(); onRequestAborted(new RestServiceException("Received request in the middle of another request", RestServiceErrorCode.BadRequest)); } return success; }</code><technical_language>content need received calling handleRequest for HTTP2? cases CopyingAsyncWritableChannel handle correctly</technical_language>

Target:
private boolean handleRequest(HttpRequest httpRequest) throws RestServiceException { boolean success = true; if (responseChannel == null || requestContentFullyReceived) { long processingStartTime = System.currentTimeMillis(); resetState(); nettyMetrics.requestArrivalRate.mark(); if (!httpRequest.decoderResult().isSuccess()) { success = false; logger.warn("Decoder failed because of malformed request on channel {}", ctx.channel(), httpRequest.decoderResult().cause()); nettyMetrics.malformedRequestError.inc(); onRequestAborted(new RestServiceException("Decoder failed because of malformed request", RestServiceErrorCode.MalformedRequest)); } else { try { if ((HttpMethod.POST.equals(httpRequest.method()) || HttpMethod.PUT.equals(httpRequest.method())) && HttpPostRequestDecoder.isMultipart(httpRequest)) { nettyMetrics.multipartPostRequestRate.mark(); request = new NettyMultipartRequest(httpRequest, ctx.channel(), nettyMetrics, nettyConfig.nettyBlacklistedQueryParams, nettyConfig.nettyMultipartPostMaxSizeBytes); } else { request = new NettyRequest(httpRequest, ctx.channel(), nettyMetrics, nettyConfig.nettyBlacklistedQueryParams); } responseChannel.setRequest(request); logger.trace("Channel now handling request {}", ctx.channel(), request.getUri()); if ((request.getRestMethod().equals(RestMethod.POST) || request.getRestMethod().equals(RestMethod.PUT)) && !HttpPostRequestDecoder.isMultipart(httpRequest)) { requestHandler.handleRequest(request, responseChannel); } } catch (RestServiceException e) { success = false; onRequestAborted(e); } finally { if (request != null) { request.getMetricsTracker().nioMetricsTracker.addToRequestProcessingTime( System.currentTimeMillis() - processingStartTime); } } } } else { success = false; logger.error("New request received when previous request is yet to be fully received on channel {}. Request under" + " processing: {}. Unexpected request: {}", ctx.channel(), request.getUri(), httpRequest.uri()); nettyMetrics.duplicateRequestError.inc(); onRequestAborted(new RestServiceException("Received request in the middle of another request", RestServiceErrorCode.BadRequest)); } return success; }