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 ; } }
If there is a content length header . Check the reported length making sure it isn t over the max post data size .