### Question:
AWSS3V4Signer extends AWS4Signer { static long getContentLength(Request<?> request) throws IOException { InputStream content = request.getContent(); if (!content.markSupported()) { throw new AmazonClientException("Failed to get content length"); } long contentLength = 0; byte[] tmp = new byte[DEFAULT_BYTE_LENGTH]; int read; content.mark(-1); while ((read = content.read(tmp)) != -1) { contentLength += read; } content.reset(); return contentLength; } AWSS3V4Signer();   }### Answer:
@Test public void testGetContentLength() throws IOException { final long len = 5 * Constants.MB; final Request<?> request = new DefaultRequest<Void>("service"); final InputStream is = new MockInputStream(len, true); request.setContent(is); assertTrue("same length", len == AWSS3V4Signer.getContentLength(request)); assertTrue("works fine after reset", len == AWSS3V4Signer.getContentLength(request)); is.close(); }