class SignedChunksInputStream extends InputStream {

  @Override
  public int read() throws IOException {
    if (remainingData > 0) {
      int curr = originalStream.read();
      remainingData--;
      if (remainingData == 0) {
        //read the "\r\n" at the end of the data section
        originalStream.read();
        originalStream.read();
      }
      return curr;
    } else {
      remainingData = readHeader();
      if (remainingData == -1) {
        return -1;
      }
      return read();
    }
  }

  public  SignedChunksInputStream(InputStream inputStream);

}