private void executeProxyRequest(HttpRequestBase proxyRequest, HttpServletRequest request,   HttpServletResponse response)  throws IOException, ServletException {
    	
    	
    	//proxyRequest.

        // Create a default HttpClient

    	HttpClientBuilder httpPre = HttpClientBuilder.create();
    	
//    	httpPre.setRedirectStrategy(new RedirectStrategy() {
//			
//			@Override
//			public boolean isRedirected(HttpRequest arg0, HttpResponse arg1,
//					HttpContext arg2) throws ProtocolException {
//				// TODO Auto-generated method stub
//				return false;
//			}
//			
//			@Override
//			public HttpUriRequest getRedirect(HttpRequest arg0, HttpResponse arg1,
//					HttpContext arg2) throws ProtocolException {
//				// TODO Auto-generated method stub
//				return null;
//			}
//		});
    	
    	HttpClient httpClient = httpPre.build();
    	

    	HttpHost targetHost = new HttpHost(proxyRequest.getFirstHeader(HOST_HEADER_NAME).getValue() , proxyRequest.getURI().getPort());
    	
    	HttpResponse httpResponse = httpClient.execute(targetHost, proxyRequest);
    	
    	int proxyResponseCode = httpResponse.getStatusLine().getStatusCode();
    	
    	
    	

        // Check if the proxy response is a redirect
        // The following code is adapted from org.tigris.noodle.filters.CheckForRedirect
        // Hooray for open source software
        if (proxyResponseCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
                && proxyResponseCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */) {

            String statusCode = Integer.toString(proxyResponseCode);
            String location   = httpResponse.getFirstHeader(LOCATION_HEADER).getValue();

            if (location == null) {
                throw new ServletException("Recieved status code: " + statusCode 
                        + " but no " +  LOCATION_HEADER + " header was found in the response");
            }

            // Modify the redirect to go to this proxy servlet rather that the proxied host
            String myHostName = request.getServerName();

            if(request.getServerPort() != 80) {
                myHostName += ":" + request.getServerPort();
            }

            myHostName += request.getContextPath();
            response.sendRedirect(location.replace(getProxyHostAndPort(), myHostName));
            return;
        } else if(proxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED) {
            // 304 needs special handling.  See:
            // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304
            // We get a 304 whenever passed an 'If-Modified-Since'
            // header and the data on disk has not changed; server
            // responds w/ a 304 saying I'm not going to send the
            // body because the file has not changed.
            response.setIntHeader(CONTENT_LENGTH_HEADER_NAME, 0);
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return;
        }
        
        // Pass the response code back to the client
        response.setStatus(proxyResponseCode);

        // Pass response headers back to the client
        Header[] responseHeaders = httpResponse.getAllHeaders();

        for (Header header : responseHeaders) {
                response.setHeader(header.getName(), header.getValue());
        }
        
        // Send the content to the client
        InputStream proxyResponse               = httpResponse.getEntity().getContent();;     
        BufferedInputStream bufferedInputStream = new BufferedInputStream(proxyResponse);
        OutputStream        clientResponse      = response.getOutputStream();

        int intNextByte;
        while ((intNextByte = bufferedInputStream.read() ) != -1 ) {
            clientResponse.write(intNextByte);
        }
        return;
        
    }