private void setResponseElements ( IntuitMessage intuitMessage , HttpURLConnection httpUrlConnection ) throws FMSException { LOG . debug ( "Response headers:" + httpUrlConnection . getHeaderFields ( ) ) ; ResponseElements responseElements = intuitMessage . getResponseElements ( ) ; responseElements . setEncodingHeader ( httpUrlConnection . getContentEncoding ( ) ) ; responseElements . setContentTypeHeader ( httpUrlConnection . getContentType ( ) ) ; try { responseElements . setStatusCode ( httpUrlConnection . getResponseCode ( ) ) ; InputStream responseStream ; try { responseStream = httpUrlConnection . getInputStream ( ) ; } catch ( IOException ioe ) { // Any error response from the server. Read the error stream instead of the responseStream. It contains the response from the server for the error code. responseStream = httpUrlConnection . getErrorStream ( ) ; } responseElements . setResponseContent ( getCopyOfResponseContent ( responseStream ) ) ; } catch ( IllegalStateException e ) { LOG . error ( "IllegalStateException while get the content from HttpRespose." , e ) ; throw new FMSException ( e ) ; } catch ( Exception e ) { LOG . error ( "IOException in HTTPURLConnectionInterceptor while reading the entity from HttpResponse." , e ) ; throw new FMSException ( e ) ; } }
Method to set the response elements by reading the values from the response