@Override
  public void channelRead0(ChannelHandlerContext ctx, HttpObject obj) throws Exception {
    logger.trace("Reading on channel {}", ctx.channel());
    if (obj instanceof HttpRequest) {
      HttpRequest request = (HttpRequest) obj;
      logger.trace("Handling incoming request {}", request);
      requestUri = request.uri();
      byte[] methodBytes = request.method().toString().getBytes();
      if (request.headers().get(IS_CHUNKED) == null || !request.headers().get(IS_CHUNKED).equals("true")) {
        response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
            Unpooled.wrappedBuffer(methodBytes));
        updateHeaders(response, request, methodBytes.length);
      } else {
        httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        HttpUtil.setTransferEncodingChunked(httpResponse, true);
        httpContentList = new ArrayList<>();
        ByteBuf content = Unpooled.wrappedBuffer(methodBytes);
        HttpContent httpContent = new DefaultHttpContent(content);
        httpContentList.add(httpContent);
        httpContentList.add(httpContent);
        updateHeaders(httpResponse, request, methodBytes.length);
      }
    } else if (obj instanceof LastHttpContent) {
      if (requestUri.equals(DISCONNECT_URI)) {
        ctx.disconnect();
      } else if (requestUri.equals(CLOSE_URI)) {
        ctx.close();
      } else {
        if (response != null) {
          ctx.writeAndFlush(response);
        } else if (httpResponse != null) {
          ctx.writeAndFlush(httpResponse);
          for (HttpContent httpContent : httpContentList) {
            ctx.writeAndFlush(httpContent);
          }
          ctx.writeAndFlush(new DefaultLastHttpContent());
        }
      }
    }
  }
Handler to echo the Method type of the request.
Used purely for testing purposes
ambry-rest/src/test/java/com/github/ambry/rest/EchoMethodHandler.java