public void execute ( ) throws HibiscusException { prepare ( ) ; httpRequest . addHeader ( "User-Agent" , getClass ( ) . getName ( ) . toUpperCase ( ) ) ; httpRequest . addHeader ( "X-Conversation-Id" , HashGenerator . getMD5Hash ( System . currentTimeMillis ( ) + "." + new Thread ( ) . getId ( ) ) ) ; // Creates a registry for HTTP and HTTPS setting default ports to 80 and 443 respectively for these schemes // HTTP uses org.apache.http.conn.scheme.PlainSocketFactory // HTTPS uses org.apache.http.conn.ssl.SSLSocketFactory SchemeRegistry registry = SchemeRegistryFactory . createDefault ( ) ; ; PoolingClientConnectionManager connManager = new PoolingClientConnectionManager ( registry ) ; // This is necessary because of https://issues.apache.org/jira/browse/HTTPCLIENT-1193 // We cannot use the Default constructor without overriding the connection manager from the default DefaultHttpClient requestClient = new DefaultHttpClient ( connManager ) ; try { final long startTime = System . currentTimeMillis ( ) ; final HttpResponse response = requestClient . execute ( httpRequest ) ; final long elapsedTime = System . currentTimeMillis ( ) - startTime ; final HttpEntity responseEntity = response . getEntity ( ) ; /* Capture the elapsed time for this request */ this . responseTime = elapsedTime ; /* This will reset the response object each time the request is made */ this . response = new Response ( ) ; /* Sets the status line and response headers */ this . response . setStatusLine ( response . getStatusLine ( ) . toString ( ) ) ; this . response . setResponseHeaders ( response . getAllHeaders ( ) ) ; if ( null != responseEntity ) { this . response . setResponseBody ( StreamUtil . inputStreamToString ( responseEntity . getContent ( ) ) ) ; } if ( log . isDebugEnabled ( ) ) { debugRequest ( response ) ; } } catch ( IOException e ) { throw new HibiscusException ( e ) ; } }
Transmits the HTTP request from the client to the server