protected ServerOperation < HttpClientResponse < O > > requestToOperation ( final HttpClientRequest < I > request , final ClientConfig rxClientConfig ) { Preconditions . checkNotNull ( request ) ; return new ServerOperation < HttpClientResponse < O > > ( ) { final AtomicInteger count = new AtomicInteger ( 0 ) ; @ Override public Observable < HttpClientResponse < O > > call ( Server server ) { HttpClient < I , O > rxClient = getOrCreateRxClient ( server ) ; setHostHeader ( request , server . getHost ( ) ) ; Observable < HttpClientResponse < O > > o ; if ( rxClientConfig != null ) { o = rxClient . submit ( request , rxClientConfig ) ; } else { o = rxClient . submit ( request ) ; } return o . concatMap ( new Func1 < HttpClientResponse < O > , Observable < HttpClientResponse < O > > > ( ) { @ Override public Observable < HttpClientResponse < O > > call ( HttpClientResponse < O > t1 ) { if ( t1 . getStatus ( ) . code ( ) / 100 == 4 || t1 . getStatus ( ) . code ( ) / 100 == 5 ) return responseToErrorPolicy . call ( t1 , backoffStrategy . call ( count . getAndIncrement ( ) ) ) ; else return Observable . just ( t1 ) ; } } ) ; } } ; }
Convert an HttpClientRequest to a ServerOperation