@ Override public CloseableHttpResponse execute ( OutgoingRequest httpRequest ) throws HttpErrorPage { OutgoingRequestContext context = httpRequest . getContext ( ) ; IncomingRequest originalRequest = httpRequest . getOriginalRequest ( ) . getOriginalRequest ( ) ; if ( cookieManager != null ) { CookieStore cookieStore = new RequestCookieStore ( cookieManager , httpRequest . getOriginalRequest ( ) ) ; context . setCookieStore ( cookieStore ) ; } HttpResponse result ; // Create request event FragmentEvent event = new FragmentEvent ( originalRequest , httpRequest , context ) ; // EVENT pre eventManager . fire ( EventManager . EVENT_FRAGMENT_PRE , event ) ; // If exit : stop immediately. if ( ! event . isExit ( ) ) { // Proceed to request only if extensions did not inject a response. if ( event . getHttpResponse ( ) == null ) { if ( httpRequest . containsHeader ( HttpHeaders . EXPECT ) ) { event . setHttpResponse ( HttpErrorPage . generateHttpResponse ( HttpStatus . SC_EXPECTATION_FAILED , "'Expect' request header is not supported" ) ) ; } else { try { HttpHost physicalHost = context . getPhysicalHost ( ) ; result = httpClient . execute ( physicalHost , httpRequest , context ) ; } catch ( IOException e ) { result = HttpErrorPage . generateHttpResponse ( e ) ; LOG . warn ( httpRequest . getRequestLine ( ) + " -> " + result . getStatusLine ( ) . toString ( ) ) ; } event . setHttpResponse ( BasicCloseableHttpResponse . adapt ( result ) ) ; } } // EVENT post eventManager . fire ( EventManager . EVENT_FRAGMENT_POST , event ) ; } CloseableHttpResponse httpResponse = event . getHttpResponse ( ) ; if ( httpResponse == null ) { throw new HttpErrorPage ( HttpStatus . SC_INTERNAL_SERVER_ERROR , "Request was cancelled by server" , "Request was cancelled by server" ) ; } if ( HttpResponseUtils . isError ( httpResponse ) ) { throw new HttpErrorPage ( httpResponse ) ; } return httpResponse ; }
Execute a HTTP request .