@Override
    public void run() {
      try {
        Path resource = new Path(resourceURI);
        Configuration conf = new Configuration();
        HttpFileSystem fs = new HttpFileSystem();
        fs.setSocketReadTimeoutMs(TIMEOUT_MS);
        fs.setConnectionTimeoutMs(TIMEOUT_MS);
        fs.setConf(conf);
        fs.initialize(resourceURI, conf);

        //Read from the socket one byte at a time.
        FSDataInputStream in = fs.open(resource);
        while (in.read() >= 0) {
          totalBytesRead++;
        }
      } catch (SocketTimeoutException e) {
        //Expect the socket to timeout after THRESHOLD bytes have been read.
        serverWaitLatch.countDown();
      } catch (Exception e) {
        //Record any exception that may have occurred.
        LOG.error("{}", e);
        clientException = e;
      }
    }
A {@link HttpServlet} implementation that streams its response to the client one byte at a time.
samza-yarn/src/test/java/org/apache/samza/job/yarn/util/hadoop/TestHttpFileSystem.java