Execute CRX HTTP Package manager method and parse XML response.
@param httpClient Http client
@param method Get or Post method
@return XML document
424223
public Document executePackageManagerMethodXml(CloseableHttpClient httpClient, HttpRequestBase method) {
    PackageManagerXmlCall call = new PackageManagerXmlCall(httpClient, method, log);
    return executeHttpCallWithRetry(call, 0);
  }
289011
private void executeRequest(HttpMethod httpMethodProxyRequest,
                                HttpServletRequest httpServletRequest,
                                PluginResponse httpServletResponse,
                                History history) throws Exception {
        int intProxyResponseCode = 999;
        // Create a default HttpClient
        HttpClient httpClient = new HttpClient();
        HttpState state = new HttpState();

        try {
            httpMethodProxyRequest.setFollowRedirects(false);
            ArrayList<String> headersToRemove = getRemoveHeaders();

            httpClient.getParams().setSoTimeout(60000);

            httpServletRequest.setAttribute("com.groupon.odo.removeHeaders", headersToRemove);

            // exception handling for httpclient
            HttpMethodRetryHandler noretryhandler = new HttpMethodRetryHandler() {
                public boolean retryMethod(
                    final HttpMethod method,
                    final IOException exception,
                    int executionCount) {
                    return false;
                }
            };

            httpMethodProxyRequest.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, noretryhandler);

            intProxyResponseCode = httpClient.executeMethod(httpMethodProxyRequest.getHostConfiguration(), httpMethodProxyRequest, state);
        } catch (Exception e) {
            // Return a gateway timeout
            httpServletResponse.setStatus(504);
            httpServletResponse.setHeader(Constants.HEADER_STATUS, "504");
            httpServletResponse.flushBuffer();
            return;
        }
        logger.info("Response code: {}, {}", intProxyResponseCode,
                    HttpUtilities.getURL(httpMethodProxyRequest.getURI().toString()));

        // Pass the response code back to the client
        httpServletResponse.setStatus(intProxyResponseCode);

        // Pass response headers back to the client
        Header[] headerArrayResponse = httpMethodProxyRequest.getResponseHeaders();
        for (Header header : headerArrayResponse) {
            // remove transfer-encoding header.  The http libraries will handle this encoding
            if (header.getName().toLowerCase().equals("transfer-encoding")) {
                continue;
            }

            httpServletResponse.setHeader(header.getName(), header.getValue());
        }

        // there is no data for a HTTP 304 or 204
        if (intProxyResponseCode != HttpServletResponse.SC_NOT_MODIFIED &&
            intProxyResponseCode != HttpServletResponse.SC_NO_CONTENT) {
            // Send the content to the client
            httpServletResponse.resetBuffer();
            httpServletResponse.getOutputStream().write(httpMethodProxyRequest.getResponseBody());
        }

        // copy cookies to servlet response
        for (Cookie cookie : state.getCookies()) {
            javax.servlet.http.Cookie servletCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());

            if (cookie.getPath() != null) {
                servletCookie.setPath(cookie.getPath());
            }

            if (cookie.getDomain() != null) {
                servletCookie.setDomain(cookie.getDomain());
            }

            // convert expiry date to max age
            if (cookie.getExpiryDate() != null) {
                servletCookie.setMaxAge((int) ((cookie.getExpiryDate().getTime() - System.currentTimeMillis()) / 1000));
            }

            servletCookie.setSecure(cookie.getSecure());

            servletCookie.setVersion(cookie.getVersion());

            if (cookie.getComment() != null) {
                servletCookie.setComment(cookie.getComment());
            }

            httpServletResponse.addCookie(servletCookie);
        }
    }
43011
def execute(self, proxy, method, args):
        """"""
        try:
            result = getattr(proxy, method)(raw_xml=self.options.xml, *tuple(args))
        except xmlrpc.ERRORS as exc:
            self.LOG.error("While calling %s(%s): %s" % (method, ", ".join(repr(i) for i in args), exc))
            self.return_code = error.EX_NOINPUT if "not find" in getattr(exc, "faultString", "") else error.EX_DATAERR
        else:
            if not self.options.quiet:
                if self.options.repr:
                    # Pretty-print if requested, or it's a collection and not a scalar
                    result = pformat(result)
                elif hasattr(result, "__iter__"):
                    result = '\n'.join(i if isinstance(i, basestring) else pformat(i) for i in result)
                print(fmt.to_console(result))
269556
private HttpResponse execute(HttpClient client, HttpUriRequest request) throws IOException {
        if (localContext != null) {
            return client.execute(request, localContext);
        } else {
            return client.execute(request);
        }
    }
735534
public static HttpResponse execute(final String url, final String method,
                                       final String basicAuthUsername,
                                       final String basicAuthPassword) {
        return execute(url, method, basicAuthUsername, basicAuthPassword, new HashMap<>(), new HashMap<>());
    }
587762
public static Predicate<HttpServerRequest> http(String uri,
			@Nullable HttpVersion protocol,
			HttpMethod method) {
		if (null == uri) {
			return null;
		}

		return new HttpPredicate(uri, protocol, method);
	}
167444
public <T> HttpClientRequest.Builder<T> get(final String uri, final HttpClientResponseHandler<T> httpHandler)
    {
        return get(URI.create(uri), httpHandler);
    }
675453
public static HttpResponse execute(final String url, final String method,
                                       final Map<String, Object> headers) {
        return execute(url, method, null, null, new HashMap<>(), headers);
    }
29963
public HTTPResponse submitHTTPRequest(HTTPRequest httpRequest,HTTPClientConfiguration httpClientConfiguration,HTTPMethod httpMethod)
    {
        //create HTTP client
        HttpClient httpClient=this.createHttpClient();
        
        //create URL
        String url=this.createURL(httpRequest,httpClientConfiguration);
        
        //create request
        HttpMethodBase httpMethodClient=this.createMethod(url,httpMethod);
        
        //setup header properties
        this.setupHTTPRequestHeaderProperties(httpRequest,httpMethodClient);

        //set content
        this.setRequestContent(httpRequest,httpMethodClient);

        //get logger
        LoggerManager loggerManager=LoggerManager.getInstance();
        Logger logger=loggerManager.getLogger();
        
        try
        {
            logger.logDebug(new Object[]{"Submitting HTTP request: ",httpMethodClient.getURI()},null);
        }
        catch(URIException exception)
        {
            logger.logDebug(new Object[]{"Submitting HTTP request"},null);
        }

        String responseContent=null;
        int statusCode=-1;
        try
        {
            //submit HTTP request
            statusCode=httpClient.executeMethod(httpMethodClient);

            if(statusCode>=400)
            {
                throw new FaxException("Error while invoking HTTP request, return status code: "+statusCode);
            }
            
            //get response content
            responseContent=httpMethodClient.getResponseBodyAsString();
        }
        catch(FaxException exception)
        {
            throw exception;
        }
        catch(Exception exception)
        {
            throw new FaxException("Error while executing HTTP request.",exception);
        }
        finally
        {
            //release connection
            httpMethodClient.releaseConnection();
        }

        //create HTTP response
        HTTPResponse httpResponse=this.createHTTPResponse(statusCode,responseContent);

        return httpResponse;
    }
1131185
public void executeMethod(final HttpMethod method) throws IOException, HttpException {
        if (method == null) {
            throw new IllegalArgumentException("Method may not be null");
        }
        // Link all parameter collections to form the hierarchy:
        // Global -> HttpClient -> HostConfiguration -> HttpMethod
        this.hostConfiguration.getParams().setDefaults(this.params);
        method.getParams().setDefaults(this.hostConfiguration.getParams());
        
        // Generate default request headers
        Collection<?> defaults = (Collection<?>)this.hostConfiguration.getParams().
			getParameter(HostParams.DEFAULT_HEADERS);
        if (defaults != null) {
        	Iterator<?> i = defaults.iterator();
        	while (i.hasNext()) {
        		method.addRequestHeader((Header)i.next());
        	}
        }
        
        try {
            int maxRedirects = this.params.getIntParameter(HttpClientParams.MAX_REDIRECTS, 100);

            for (int redirectCount = 0;;) {

                // make sure the connection we have is appropriate
                if (this.conn != null && !hostConfiguration.hostEquals(this.conn)) {
                    this.conn.setLocked(false);
                    this.conn.releaseConnection();
                    this.conn = null;
                }
        
                // get a connection, if we need one
                if (this.conn == null) {
                    this.conn = connectionManager.getConnectionWithTimeout(
                        hostConfiguration,
                        this.params.getConnectionManagerTimeout() 
                    );
                    this.conn.setLocked(true);
                    if (this.params.isAuthenticationPreemptive()
                     || this.state.isAuthenticationPreemptive()) 
                    {
                        LOG.debug("Preemptively sending default basic credentials");
                        method.getHostAuthState().setPreemptive();
                        method.getHostAuthState().setAuthAttempted(true);
                        if (this.conn.isProxied() && !this.conn.isSecure()) {
                            method.getProxyAuthState().setPreemptive();
                            method.getProxyAuthState().setAuthAttempted(true);
                        }
                    }
                }
                authenticate(method);
                executeWithRetry(method);
                if (this.connectMethod != null) {
                    fakeResponse(method);
                    break;
                }
                
                boolean retry = false;
                if (isRedirectNeeded(method)) {
                    if (processRedirectResponse(method)) {
                        retry = true;
                        ++redirectCount;
                        if (redirectCount >= maxRedirects) {
                            LOG.error("Narrowly avoided an infinite loop in execute");
                            throw new RedirectException("Maximum redirects ("
                                + maxRedirects + ") exceeded");
                        }
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Execute redirect " + redirectCount + " of " + maxRedirects);
                        }
                    }
                }
                if (isAuthenticationNeeded(method)) {
                    if (processAuthenticationResponse(method)) {
                        LOG.debug("Retry authentication");
                        retry = true;
                    }
                }
                if (!retry) {
                    break;
                }
                // retry - close previous stream.  Caution - this causes
                // responseBodyConsumed to be called, which may also close the
                // connection.
                if (method.getResponseBodyAsStream() != null) {
                    method.getResponseBodyAsStream().close();
                }

            } //end of retry loop
        } finally {
            if (this.conn != null) {
                this.conn.setLocked(false);
            }
            // If the response has been fully processed, return the connection
            // to the pool.  Use this flag, rather than other tests (like
            // responseStream == null), as subclasses, might reset the stream,
            // for example, reading the entire response into a file and then
            // setting the file as the stream.
            if (
                (releaseConnection || method.getResponseBodyAsStream() == null) 
                && this.conn != null
            ) {
                this.conn.releaseConnection();
            }
        }

    }
933554
public static <T> T executeXmlResult(HttpUriRequest request,Class<T> clazz){
		return execute(request,XmlResponseHandler.createResponseHandler(clazz));
	}
727161
public static HttpResponse getResponse(String urls, HttpRequest request,
                                           HttpMethod method, int connectTimeoutMillis, int readTimeoutMillis) throws IOException {
        OutputStream out = null;
        InputStream content = null;
        HttpResponse response = null;
        HttpURLConnection httpConn = request
            .getHttpConnection(urls, method.name());
        httpConn.setConnectTimeout(connectTimeoutMillis);
        httpConn.setReadTimeout(readTimeoutMillis);

        try {
            httpConn.connect();
            if (null != request.getPayload() && request.getPayload().length > 0) {
                out = httpConn.getOutputStream();
                out.write(request.getPayload());
            }
            content = httpConn.getInputStream();
            response = new HttpResponse();
            parseHttpConn(response, httpConn, content);
            return response;
        } catch (SocketTimeoutException e) {
            throw e;
        } catch (IOException e) {
            content = httpConn.getErrorStream();
            response = new HttpResponse();
            parseHttpConn(response, httpConn, content);
            return response;
        } finally {
            if (content != null) {
                content.close();
            }
            httpConn.disconnect();
        }
    }
472905
public HttpRequest method(Method method) {
		if (Method.PATCH == method) {
			this.method = Method.POST;
			this.header("X-HTTP-Method-Override", "PATCH");
		} else {
			this.method = method;
		}
		return this;
	}
1253297
public static HttpResponse execute(final String url, final String method,
                                       final String basicAuthUsername, final String basicAuthPassword,
                                       final Map<String, Object> headers) {
        return execute(url, method, basicAuthUsername, basicAuthPassword, new HashMap<>(), headers);
    }
1051599
private function doApiCall($url, $method, $access_token = null, $parameters = [], $contentType = 'text/xml')
    {
        $request = [];
        $headers = [];

        $request[CURLOPT_TIMEOUT]       = (int) $this->http_timeout;
        $request[CURLOPT_USERAGENT]     = str_replace('%VERSION%', Client::VERSION, $this->http_user_agent);
        $request[CURLOPT_CUSTOMREQUEST] = $method;

        if (isset($parameters['Ocp-Apim-Subscription-Key'])) {
            $headers[] = "Ocp-Apim-Subscription-Key: ".$parameters['Ocp-Apim-Subscription-Key'];
            $headers[] = "Content-Length: 0";
            unset($parameters['Ocp-Apim-Subscription-Key']);
        }

        if (! empty($parameters)) {
            if ($method === 'GET') {
                $url = Tools::httpBuildUrl($url, ["query" => http_build_query($parameters)], Tools::HTTP_URL_JOIN_QUERY);
            } else {
                if (is_array($parameters)) {
                    $request[CURLOPT_POSTFIELDS] = http_build_query($parameters);
                } else {
                    if (is_string($parameters)) {
                        $request[CURLOPT_POSTFIELDS] = $parameters;
                    }
                }
            }
        }

        $request[CURLOPT_URL] = $url;

        if (! is_null($contentType)) {
            $headers[] = "Content-Type: $contentType";
        }

        if (! is_null($access_token)) {
            $headers[] = 'Authorization: Bearer '.$access_token;
        }

        if (! empty($this->http_proxy_host)) {
            $request[CURLOPT_PROXY] = $this->http_proxy_host;

            if (! empty($this->http_proxy_port)) {
                $request[CURLOPT_PROXYPORT] = $this->http_proxy_port;
            }

            if (! empty($this->http_proxy_type)) {
                $request[CURLOPT_PROXYTYPE] = $this->http_proxy_type;
            }

            if (! empty($this->http_proxy_auth)) {
                $request[CURLOPT_PROXYAUTH] = $this->http_proxy_auth;
            }

            if (! empty($this->http_proxy_user)) {
                $request[CURLOPT_PROXYUSERPWD] = $this->http_proxy_user.':'.$this->http_proxy_pass;
            }
        }

        $request[CURLOPT_HTTPHEADER] = $headers;

        $this->logger->info(__CLASS__, 'api', sprintf('%s %s', $method, $url));

        $start = microtime(true);
        @list($result, $status_code, $error, $errno) = $this->execCurl($request);
        $end = microtime(true);

        $duration = (int) round(($end - $start) * 1000);

        if ($errno === 0) {
            $return = [
                'http_code' => $status_code,
                'http_body' => $result,
                'duration'  => $duration,
            ];

            if ($status_code >= 400) {
                $this->logger->error(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
            } else {
                if ($status_code >= 300) {
                    $this->logger->warning(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
                } else {
                    $this->logger->info(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms', $status_code, strlen($result), $duration));
                }
            }
        } else {
            $return = [
                'error_msg' => $error,
                'error_num' => $errno,
                'duration'  => $duration,
            ];

            $this->logger->error(__CLASS__, 'api', sprintf('cURL error #%s : %s', $errno, $error));
        }

        return $return;
    }
1120925
private HttpResponse executeRequest(HttpPost request) throws Exception {
        try {
            HttpClient httpClient = connection.getHttpClient();
            HttpContext httpContext = connection.getHttpContext();
            HttpResponse response = httpClient.execute(request, httpContext);
            return response;
        } catch (Exception e) {
            throw MwsUtl.wrap(e);
        }
    }
1004999
private static HttpUriRequest createHttpUriRequest(String method, URI uri) {
        switch (method) {
            case "GET":
                return new HttpGet(uri);
            case "HEAD":
                return new HttpHead(uri);
            case "POST":
                return new HttpPost(uri);
            case "PUT":
                return new HttpPut(uri);
            case "PATCH":
                return new HttpPatch(uri);
            case "DELETE":
                return new HttpDelete(uri);
            case "OPTIONS":
                return new HttpOptions(uri);
            case "TRACE":
                return new HttpTrace(uri);
            default:
                throw new IllegalArgumentException("Invalid HTTP method: " + method);
        }
    }