protected boolean hasContentLength ( ) { boolean result = false ; String contentLength = this . request . getHeader ( RestMessageHeaders . CONTENT_LENGTH ) ; if ( contentLength != null ) { try { Long . parseLong ( contentLength ) ; result = true ; } catch ( NumberFormatException nfe ) { logger . error ( "Exception when validating put request. Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe . getMessage ( ) , nfe ) ; RestErrorHandler . writeErrorResponse ( this . messageEvent , HttpResponseStatus . BAD_REQUEST , "Incorrect content length parameter. Cannot parse this to long: " + contentLength + ". Details: " + nfe . getMessage ( ) ) ; } } else { logger . error ( "Error when validating put request. Missing Content-Length header." ) ; RestErrorHandler . writeErrorResponse ( this . messageEvent , HttpResponseStatus . BAD_REQUEST , "Missing Content-Length header" ) ; } return result ; }
Retrieves and validates the content length from the REST request .