code:     public int doRead(ByteChunk chunk, Request req) throws IOException {
  
          if (endChunk) {
              return -1;
          }
  
          if(needCRLFParse) {
              needCRLFParse = false;
              parseCRLF(false);
          }
  
          if (remaining <= 0) {
              if (!parseChunkHeader()) {
                  throw new IOException("Invalid chunk header");
              }
              if (endChunk) {
                  parseEndChunk();
                  return -1;
              }
          }
  
          int result = 0;
  
          if (pos >= lastValid) {
              if (readBytes() < 0) {
                  throw new IOException(
                          "Unexpected end of stream whilst reading request body");
              }
          }
  
          if (remaining > (lastValid - pos)) {
              result = lastValid - pos;
              remaining = remaining - result;
              chunk.setBytes(buf, pos, result);
              pos = lastValid;
          } else {
              result = remaining;
              chunk.setBytes(buf, pos, remaining);
              pos = pos + remaining;
              remaining = 0;
              //we need a CRLF
              if ((pos+1) >= lastValid) {
                  //if we call parseCRLF we overrun the buffer here
                  //so we defer it to the next call BZ 11117
                  needCRLFParse = true;
              } else {
                  parseCRLF(false); //parse the CRLF immediately
              }
          }
  
          return result;
      }
  
  
      // ---------------------------------------------------- InputFilter Methods
  
      /**
       * Read the content length from the request.
       */
      @Override
  