@Test
  public void sizeTest() throws RestServiceException {
    // no length headers provided.
    NettyRequest nettyRequest = createNettyRequest(HttpMethod.GET, "/", null, new MockChannel());
    assertEquals("Size not as expected", -1, nettyRequest.getSize());

    // deliberate mismatch to check priorities.
    int xAmbryBlobSize = 20;
    int contentLength = 10;

    // Content-Length header set
    HttpHeaders headers = new DefaultHttpHeaders();
    headers.add(HttpHeaderNames.CONTENT_LENGTH, contentLength);
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", headers, new MockChannel());
    assertEquals("Size not as expected", contentLength, nettyRequest.getSize());

    // xAmbryBlobSize set
    headers = new DefaultHttpHeaders();
    headers.add(RestUtils.Headers.BLOB_SIZE, xAmbryBlobSize);
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", headers, new MockChannel());
    assertEquals("Size not as expected", xAmbryBlobSize, nettyRequest.getSize());

    // both set
    headers = new DefaultHttpHeaders();
    headers.add(RestUtils.Headers.BLOB_SIZE, xAmbryBlobSize);
    headers.add(HttpHeaderNames.CONTENT_LENGTH, contentLength);
    nettyRequest = createNettyRequest(HttpMethod.GET, "/", headers, new MockChannel());
    assertEquals("Size not as expected", xAmbryBlobSize, nettyRequest.getSize());
  }
Tests the {@link NettyRequest#getSize()} function to see that it respects priorities.
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyRequestTest.java