public static Object getRequestBody ( PageContext pc , boolean deserialized , Object defaultValue ) { HttpServletRequest req = pc . getHttpServletRequest ( ) ; MimeType contentType = getContentType ( pc ) ; String strContentType = contentType == MimeType . ALL ? null : contentType . toString ( ) ; Charset cs = getCharacterEncoding ( pc , req ) ; boolean isBinary = ! ( strContentType == null || HTTPUtil . isTextMimeType ( contentType ) || strContentType . toLowerCase ( ) . startsWith ( "application/x-www-form-urlencoded" ) ) ; if ( req . getContentLength ( ) > - 1 ) { ServletInputStream is = null ; try { byte [ ] data = IOUtil . toBytes ( is = req . getInputStream ( ) ) ; // new byte[req.getContentLength()]; Object obj = NULL ; if ( deserialized ) { int format = MimeType . toFormat ( contentType , - 1 ) ; obj = toObject ( pc , data , format , cs , obj ) ; } if ( obj == NULL ) { if ( isBinary ) obj = data ; else obj = toString ( data , cs ) ; } return obj ; } catch ( Exception e ) { pc . getConfig ( ) . getLog ( "application" ) . error ( "request" , e ) ; return defaultValue ; } finally { IOUtil . closeEL ( is ) ; } } return defaultValue ; }
returns the body of the request