private void lengthOfRequestEntity(ContainerRequestContext request) throws IOException {
  if (request.getLength() == -1 && request.hasEntity()) {
    InputStream istream=request.getEntityStream();
    if (!istream.markSupported()) {
      istream=new BufferedInputStream(istream);
    }
    istream.mark(MAX_ENTITY_SIZE + 1);
    byte[] entity=new byte[MAX_ENTITY_SIZE + 1];
    int entitySize=istream.read(entity);
    if (entitySize > MAX_ENTITY_SIZE) {
      request.setProperty(PROPERTY_REQ_LEN,-1);
    }
 else {
      request.setProperty(PROPERTY_REQ_LEN,entitySize);
    }
    istream.reset();
    request.setEntityStream(istream);
  }
 else {
    request.setProperty(PROPERTY_REQ_LEN,request.getLength());
  }
}

private void lengthOfRequestEntity ( ContainerRequestContext request ) throws IOException { if ( request . getLength ( ) == - 1 && request . hasEntity ( ) ) { InputStream istream = request . getEntityStream ( ) ; if ( ! istream . markSupported ( ) ) { istream = new BufferedInputStream ( istream ) ; } istream . mark ( MAX_ENTITY_SIZE + 1 ) ; byte [ ] entity = new byte [ MAX_ENTITY_SIZE + 1 ] ; int entitySize = istream . read ( entity ) ; if ( entitySize > MAX_ENTITY_SIZE ) { request . setProperty ( PROPERTY_REQ_LEN , - 1 ) ; } else { request . setProperty ( PROPERTY_REQ_LEN , entitySize ) ; } istream . reset ( ) ; request . setEntityStream ( istream ) ; } else { request . setProperty ( PROPERTY_REQ_LEN , request . getLength ( ) ) ; } }
if content - length not defined , finds length of request stream and sets property_req_len .
