public < T > T execute ( WebDriverLikeRequest request ) { Response response = null ; long total = 0 ; try { HttpClient client = newHttpClientWithTimeout ( ) ; String url = remoteURL + request . getPath ( ) ; BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest ( request . getMethod ( ) , url ) ; if ( request . hasPayload ( ) ) { r . setEntity ( new StringEntity ( request . getPayload ( ) . toString ( ) , "UTF-8" ) ) ; } HttpHost h = new HttpHost ( remoteURL . getHost ( ) , remoteURL . getPort ( ) ) ; long start = System . currentTimeMillis ( ) ; HttpResponse res = client . execute ( h , r ) ; total = System . currentTimeMillis ( ) - start ; response = Helper . exctractResponse ( res ) ; } catch ( Exception e ) { throw new WebDriverException ( e ) ; } response = errorHandler . throwIfResponseFailed ( response , total ) ; try { return cast ( response . getValue ( ) ) ; } catch ( ClassCastException e ) { log . warning ( e . getMessage ( ) + " for " + response . getValue ( ) ) ; throw e ; } }
send the request to the remote server for execution .