private String clientResponseToString ( ClientResponse response ) { if ( response == null ) { return null ; } StringBuilder builder = new StringBuilder ( ) ; builder . append ( "[status: " ) . append ( response . getStatus ( ) ) ; builder . append ( ", media type: " ) . append ( response . getType ( ) ) ; if ( response . getStatus ( ) != 404 ) { try { String responseBody = response . getEntity ( String . class ) ; if ( responseBody != null ) { builder . append ( ", response body: " ) . append ( responseBody ) ; } } catch ( RuntimeException ignore ) { // Ignore if there is no response body, or IO error - it may have already been read in certain scenario. } } builder . append ( ", response headers: " ) . append ( response . getHeaders ( ) ) ; builder . append ( "]" ) ; return builder . toString ( ) ; }
Converts ClientResponse object to string with detailed debug information including status code media type response headers and response body if exists .