public ResponseOnSingeRequest onComplete ( Response response ) { cancelCancellable ( ) ; try { Map < String , List < String > > responseHeaders = null ; if ( responseHeaderMeta != null ) { responseHeaders = new LinkedHashMap < String , List < String > > ( ) ; if ( responseHeaderMeta . isGetAll ( ) ) { for ( Map . Entry < String , List < String > > header : response . getHeaders ( ) ) { responseHeaders . put ( header . getKey ( ) . toLowerCase ( Locale . ROOT ) , header . getValue ( ) ) ; } } else { for ( String key : responseHeaderMeta . getKeys ( ) ) { if ( response . getHeaders ( ) . containsKey ( key ) ) { responseHeaders . put ( key . toLowerCase ( Locale . ROOT ) , response . getHeaders ( ) . get ( key ) ) ; } } } } int statusCodeInt = response . getStatusCode ( ) ; String statusCode = statusCodeInt + " " + response . getStatusText ( ) ; String charset = ParallecGlobalConfig . httpResponseBodyCharsetUsesResponseContentType && response . getContentType ( ) != null ? AsyncHttpProviderUtils . parseCharset ( response . getContentType ( ) ) : ParallecGlobalConfig . httpResponseBodyDefaultCharset ; if ( charset == null ) { getLogger ( ) . error ( "charset is not provided from response content type. Use default" ) ; charset = ParallecGlobalConfig . httpResponseBodyDefaultCharset ; } reply ( response . getResponseBody ( charset ) , false , null , null , statusCode , statusCodeInt , responseHeaders ) ; } catch ( IOException e ) { getLogger ( ) . error ( "fail response.getResponseBody " + e ) ; } return null ; }
On complete . Save response headers when needed .