Request

Make request with API url and specific URL suffix

@param string $urlSuffix API URL method
@param array  $options   Options

@return ResponseInterface
433079
protected function request($urlSuffix, array $options)
    {
        $client = new Client([
            'base_uri' => $this->blizzardClient->getApiUrl(),
        ]);

        $options = $this->generateQueryOptions($options);

        return $client->get($this->serviceParam.$urlSuffix, $options);
    }
33623
public function curlOpts( array $options )
      : Request
   {

      $this->_curlOpts = \array_merge( $this->_curlOpts, $options );

      return $this;

   }
279789
public function request(RequestInterface $request, array $options = []): HttpResultInterface
    {
        $options = $this->handleOptions(array_merge($this->defaultOptions, $options));

        $url = (string)$request->getUri();
        $profileKey = 'HttpClient.' . $url;

        App::profileStart($profileKey);

        list($host, $port) = $this->ipResolve($request, $options);

        $ssl = $request->getUri()->getScheme() === 'https';

        $client = new CoHttpClient($host, $port, $ssl);
        $this->applyOptions($client, $request, $options);
        $this->applyMethod($client, $request, $options);

        $path = $request->getUri()->getPath();
        $query = $request->getUri()->getQuery();
        if ($path === '') $path = '/';
        if ($query !== '') $path .= '?' . $query;

        $client->setDefer();
        $client->execute($path);

        App::profileEnd($profileKey);

        if (null !== $client->errCode && $client->errCode !== 0) {
            App::error(sprintf('HttpClient Request ERROR #%s url=%s', $client->errCode, $url));
            throw new RuntimeException(\socket_strerror($client->errCode), $client->errCode);
        }

        $result = new HttpCoResult(null, $client, $profileKey);
        return $result;
    }
1336629
final protected function getRedirectResponse($location, $addSuffix = true)
    {
        $url = $this->request()->getAppUrl();
        $url .= $location;
        if ($addSuffix) {
            $url .= $this->request()->getSuffix();
        }
        return $this->getRedirectUrlResponse($url);
    }
346183
public function requestRaw(string $url, string $method = 'GET', array $options = [])
    {
        return Response::buildFromPsrResponse($this->request($url, $method, $options, true));
    }
571228
public function makeRequest($url, $options = [], $parseResponse = true)
    {
        $headers = isset($options['headers']) ? $options['headers'] : [];
        $options['headers'] = array_merge($this->getExtraApiHeaders(), $headers);

        return parent::makeRequest($url, $options, $parseResponse);
    }
965389
public function get($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'GET', $params, $options);
	}
922507
protected function createRequest($method, $url, $token, array $options)
    {
        $defaults = [
            'headers' => $this->getHeaders($token),
        ];

        $options = array_merge_recursive($defaults, $options);
        $factory = $this->getRequestFactory();

        return $factory->getRequestWithOptions($method, $url, $options);
    }
435304
public function getEvidenceURL($urlSuffix = null)
    {
        if (is_null($urlSuffix)) {
            $urlSuffix = $this->evidence;
        }

        $url = $this->url.$this->prefix.'/'.$this->company;
        if (!empty($urlSuffix)) {
            $url .= (($urlSuffix[0] == '.') ? '' : '/').$urlSuffix;
        }
        return $url;
    }
1304637
public function loadFromUrlByProxy($url, $options = [], CurlInterface $curl = null, $proxy = null)
    {
        //$proxy = "120.195.203.43:80";
        //$proxy = explode(':', $proxy);

        if (is_null($curl))
        {
            // use the default curl interface
            $curl = new CurlProxy;
        }
        $content = $curl->get($url, $proxy);

        return $this->loadStr($content, $options);
    }
998448
public function request(string $method, $uri, array $options = []): HttpResultInterface
    {
        $options = $this->prepareDefaults($options);
        $headers = $options['headers'] ?? [];
        $body = $options['body'] ?? null;
        $version = $options['version'] ?? '1.1';
        // Merge the URI into the base URI.
        $uri = $this->buildUri($uri, $options);
        $profileKey = 'http.' . (string)$uri;
        App::profileStart($profileKey);
        $request = new Request($method, $uri, $headers, $body, $version);
        $adapter = $this->getAdapter();
        $this->setDefaultUserAgent();
        $result = $adapter->request($request, $options);
        App::profileEnd($profileKey);
        return $result;
    }
1128559
public function send(string $method, string $url, array $options)
    {
        try {
            // Guzzle overwrites all query string values in the URI if queries are specified
            // in the 'query' option, so they need to be extracted first.
            $optionsPayload = $this->mergeOptions(
                ['query' => $this->parseQueryParams($url)],
                $options
            );

            $response = $this->buildClient()->request($method, $url, $optionsPayload);

            return $this->buildResponse($response);
        } catch (GuzzleException $exception) {
            // No "custom" exceptions, just rethrow whatever guzzle spits out.
            throw $exception;
        }
    }
360934
private function sendRequest($method, $url, array $options = [])
    {
        $response = $this->httpClient->request((string)$method, $url, $options);

        return json_decode($response->getBody(), true);
    }
1339382
public function request($url, array $options = array()) {
    // Initialize a curl
    $curl = curl_init($url);
    // If there's options
    if ($options) {
      // Set options
      curl_setopt_array($curl, $options);
    }
    // Execute
    $response = curl_exec($curl);
    // Get header size
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    // Get body
    $body = substr($response, $headerSize);
    // Get status
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    // Parse header
    $headers = $this->parseHeaders(substr($response, 0, $headerSize));
    // Close curl
    curl_close($curl);
    // Return response
    return new Response($body, $status, $headers);
  }
1249794
public function getRequest($method, $url, array $options = [])
    {
        return $this->createRequest($method, $url, null, $options);
    }
720754
protected static function _staticRequest($method, $url, $params, $options)
    {
        $opts = \Stripe\Util\RequestOptions::parse($options);
        $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
        $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
        list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
        $opts->discardNonPersistentHeaders();
        return [$response, $opts];
    }
688642
public function request(array $curl_options)
	{
		$curl = $this->_init($curl_options);
		$response = $this->_execute($curl);

		// Execute response
		if ($response === FALSE)
		{
			$this->_handle_error($curl);

			return FALSE;
		}

		$this->_close($curl);

		return $response;
	}