Source:
public FullHttpResponse process(FullHttpRequest request) { if (HttpUtil.is100ContinueExpected(request)) { return new DefaultFullHttpResponse(HTTP_1_1, CONTINUE); } ByteBuf body = request.content(); ByteBuf outputBuffer = Unpooled.EMPTY_BUFFER; try { outputBuffer = processFrame(body); } catch (TException e) { LOGGER.error("Frugal processor returned unhandled error:", e); return new DefaultFullHttpResponse( HTTP_1_1, INTERNAL_SERVER_ERROR); } catch (IOException e) { LOGGER.error("Frugal processor invalid frame:", e); return new DefaultFullHttpResponse( HTTP_1_1, BAD_REQUEST); } Integer responseLimit = getResponseLimit(request.headers()); if (responseLimit > 0 && outputBuffer.readableBytes() > responseLimit) { LOGGER.error("Response size too large for client"); return new DefaultFullHttpResponse( HTTP_1_1, REQUEST_ENTITY_TOO_LARGE); } FullHttpResponse response = new DefaultFullHttpResponse( HTTP_1_1, OK, outputBuffer); DefaultHttpHeaders headers = (DefaultHttpHeaders) response.headers(); for (Map.Entry<String, String> header : this.customHeaders) { headers.set(header.getKey(), header.getValue()); } ZonedDateTime dateTime = ZonedDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; headers.set(DATE, dateTime.format(formatter)); headers.set(CONTENT_TYPE, "application/x-frugal"); headers.set(CONTENT_TRANSFER_ENCODING, "base64"); headers.set(CONTENT_LENGTH, Integer.toString(outputBuffer.readableBytes())); return response; }

Target:
public FullHttpResponse process(FullHttpRequest request) { if (HttpUtil.is100ContinueExpected(request)) { return new DefaultFullHttpResponse(HTTP_1_1, CONTINUE); } ByteBuf body = request.content(); ByteBuf outputBuffer = Unpooled.EMPTY_BUFFER; try { outputBuffer = processFrame(body); } catch (TException e) { LOGGER.error("Frugal processor returned unhandled error:", e); String errorMessage = ""; if (e.getMessage() != null) { errorMessage = e.getMessage(); } return new DefaultFullHttpResponse( HTTP_1_1, INTERNAL_SERVER_ERROR, Unpooled.copiedBuffer(errorMessage.getBytes())); } catch (IOException e) { LOGGER.error("Frugal processor invalid frame:", e); String errorMessage = ""; if (e.getMessage() != null) { errorMessage = e.getMessage(); } return new DefaultFullHttpResponse( HTTP_1_1, BAD_REQUEST, Unpooled.copiedBuffer(errorMessage.getBytes())); } Integer responseLimit = getResponseLimit(request.headers()); if (responseLimit > 0 && outputBuffer.readableBytes() > responseLimit) { LOGGER.error("Response size too large for client." + " Received: " + outputBuffer.readableBytes() + ", Limit: " + responseLimit); return new DefaultFullHttpResponse( HTTP_1_1, REQUEST_ENTITY_TOO_LARGE); } FullHttpResponse response = new DefaultFullHttpResponse( HTTP_1_1, OK, outputBuffer); DefaultHttpHeaders headers = (DefaultHttpHeaders) response.headers(); for (Map.Entry<String, String> header : this.customHeaders) { headers.set(header.getKey(), header.getValue()); } ZonedDateTime dateTime = ZonedDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; headers.set(DATE, dateTime.format(formatter)); headers.set(CONTENT_TYPE, "application/x-frugal"); headers.set(CONTENT_TRANSFER_ENCODING, "base64"); headers.set(CONTENT_LENGTH, Integer.toString(outputBuffer.readableBytes())); return response; }