code: private int parseContentLength(int maxPostDataSize, String length) {
          if(length!=null) {
              try {
                  int size = Integer.parseInt(length);
                  if(size>maxPostDataSize) return -1;
                  else return size;
              } catch(NumberFormatException e) {
                  // should never occur.  invalid content length i.e. abc, is usually
                  // caught by the container.  However, a user could specify a Content-Length with
                  // a value larger than an int max size
                  return -1;
              }
          } else {
              return -2;
          }
      }
docs: If there is a content length header.  Check the reported length, making sure
  it isn't over the max post data size.
  
  @param maxPostDataSize
  @return -1 if size of post data is too large, or corrupt, -2 if we don't have content length (chunked),
  or the size (this could be 0)