private static Response wrap ( final Response res , final Fallback fbk , final Request req ) { // @checkstyle AnonInnerLengthCheck (50 lines) return new Response ( ) { @ Override public Iterable < String > head ( ) throws IOException { final long start = System . currentTimeMillis ( ) ; Iterable < String > head ; try { head = res . head ( ) ; } catch ( final HttpException ex ) { head = fbk . route ( TkFallback . fallback ( req , start , ex , ex . code ( ) ) ) . get ( ) . head ( ) ; } catch ( final Throwable ex ) { head = fbk . route ( TkFallback . fallback ( req , start , ex , HttpURLConnection . HTTP_INTERNAL_ERROR ) ) . get ( ) . head ( ) ; } return head ; } @ Override public InputStream body ( ) throws IOException { final long start = System . currentTimeMillis ( ) ; InputStream body ; try { body = res . body ( ) ; } catch ( final HttpException ex ) { body = fbk . route ( TkFallback . fallback ( req , start , ex , ex . code ( ) ) ) . get ( ) . body ( ) ; } catch ( final Throwable ex ) { body = fbk . route ( TkFallback . fallback ( req , start , ex , HttpURLConnection . HTTP_INTERNAL_ERROR ) ) . get ( ) . body ( ) ; } return body ; } } ; }
Wrap response .