private boolean execute ( boolean readResponse ) throws IOException { try { httpEngine . sendRequest ( ) ; route = httpEngine . getRoute ( ) ; handshake = httpEngine . getConnection ( ) != null ? httpEngine . getConnection ( ) . getHandshake ( ) : null ; if ( readResponse ) { httpEngine . readResponse ( ) ; } return true ; } catch ( RequestException e ) { // An attempt to interpret a request failed. IOException toThrow = e . getCause ( ) ; httpEngineFailure = toThrow ; throw toThrow ; } catch ( RouteException e ) { // The attempt to connect via a route failed. The request will not have been sent. HttpEngine retryEngine = httpEngine . recover ( e ) ; if ( retryEngine != null ) { httpEngine = retryEngine ; return false ; } // Give up; recovery is not possible. IOException toThrow = e . getLastConnectException ( ) ; httpEngineFailure = toThrow ; throw toThrow ; } catch ( IOException e ) { // An attempt to communicate with a server failed. The request may have been sent. HttpEngine retryEngine = httpEngine . recover ( e ) ; if ( retryEngine != null ) { httpEngine = retryEngine ; return false ; } // Give up; recovery is not possible. httpEngineFailure = e ; throw e ; } }
Sends a request and optionally reads a response . Returns true if the request was successfully executed and false if the request can be retried . Throws an exception if the request failed permanently .