Detects which HTTP client handler to use.

@return HttpClientInterface
4189
public function detectHttpClientHandler()
    {
        $handler = null;
        if (class_exists('GuzzleHttp\Client')) {
            $handler = new GuzzleHttpClient();
        } elseif (function_exists('curl_init')) {
            $handler = new CurlHttpClient();
        } else {
            $handler = new StreamHttpClient();
        }
        return $handler;
    }
1366139
public function getHttpClient()
    {
        if (!is_object($this->_httpClient)) {
            $this->_httpClient = new Client([
                'requestConfig' => [
                    'options' => [
                        'timeout' => 30,
                    ]
                ],
                'responseConfig' => [
                    'format' => Client::FORMAT_JSON
                ],
            ]);
            $this->_httpClient->on(Client::EVENT_BEFORE_SEND, function (RequestEvent $event) {
                $url = $event->request->getUrl();
                if (is_array($url)) {
                    $url = array_merge($url, [Yii::$app->wechat->accessToken->queryName => Yii::$app->wechat->accessToken->getToken()]);
                } else {
                    $url = [$url, Yii::$app->wechat->accessToken->queryName => Yii::$app->wechat->accessToken->getToken()];
                }
                $event->request->setUrl($url);
            });
        }
        return $this->_httpClient;
    }
407051
protected function registerErrorHandler()
    {
        Event::listen('exception.beforeRender', function ($exception, $httpCode, $request) {
            $handler = new ErrorHandler;
            return $handler->handleException($exception);
        });
    }
955027
protected function constructHttpClient()
    {
        $hasHttpClient = (null !== $this->httpClient);

        $this->httpClient = new HttpClient($this->getOptions());

        if (!$hasHttpClient) {
            $this->httpClient->registerDefaults();
        }
    }
1084986
public function getHttpAdapter()
    {
        if (null === $this->httpAdapter) {
            $this->httpAdapter = new Http\Client\Adapter\Curl();
            $this->httpAdapter->setOptions(array(
                'curloptions' => array(
                    CURLOPT_SSL_VERIFYPEER => false,
                ),
            ));
        }

        return $this->httpAdapter;
    }
1109535
public function getHandler()
    {
        if (!$this->handler) {
            return $this->getDefaultHandler();
        }

        if (is_callable($this->handler)) {
            $this->handler = call_user_func($this->handler);
        }

        return $this->handler;
    }
38543
protected function httpClient()
    {
        if (null === $this->obj_http_client) {
            $this->obj_http_client = $this->initHttpClient();
        }
        return $this->obj_http_client;
    }
1195898
private function identifyClientFromRequest()
  {
    $clientId   = $this->getRequest()->input('client_id', '');
    $clientSecret = $this->getRequest()->input('client_secret', null);
    $redirectUri  = $this->getRequest()->input('redirect_uri', null);

    try {
      $this->accessToken  = $this->getResource()->determineAccessToken();

      $sessionRepository = new FluentSession();
      $sesion      = $sessionRepository->validateAccessToken($this->accessToken);

      if ($sesion !== false) {
        $clientId   = $sesion['client_id'];
        $clientSecret = $sesion['client_secret'];
      }

      unset($sessionRepository);
      unset($sesion);
    } catch (InvalidAccessTokenException $e) {}

    if ( ! empty($clientId)) {
      $clientRepository = new FluentClient();
      $client       = $clientRepository->getClient($clientId, $clientSecret, $redirectUri);

      if ($client !== false) {
        $client['id']   = $clientId;
        $client['secret'] = $client['client_secret'];

        unset($client['client_id']);
        unset($client['client_secret']);
        unset($client['redirect_uri']);
        unset($client['metadata']);

        $this->client = new OauthClient();

        $this->client->fill($client);
        $this->client->exists = true;
        $this->client->syncOriginal();
      }

      unset($client);
      unset($clientRepository);
    }

    unset($clientId);
    unset($clientSecret);
    unset($redirectUri);
  }
126592
private function getClientInternal($type = null) {
		if ($type != null) {
			if (isset($this->clients[$type])) {
				return $this->clients[$type];
			} else {
				throw new \Exception("No http client with type '$type' found.");
			}
		} else {
			foreach ($this->clients as $client) {
				if ($client->isSupported()) {
					return $client;
				}
			}
			throw new \Exception('No supported http client found.');
		}
	}
282893
public function initHttpClients()
    {
        $clientConfig = $this->config->getHttpClientConfig();
        $authClient = new HttpClient($clientConfig);
        $this->setAuthHttpClient($authClient);

        $clientConfig['handler'] = $this->initHandlerStack();
        $client = new HttpClient($clientConfig);
        $this->setHttpClient($client);
    }
916172
public function bindApiClient()
    {
        $this->app->singleton(ApiClient::class, function (Application $app) {
            $http = $app->make(HttpClient::class);

            return new ApiClient($http);
        });
    }
1264366
public static function handleRequest()
    {
        // save static class
        static::$calledClass = get_called_class();

        // handle JSON requests
        if (static::peekPath() == 'json') {
            // check access for API response modes
            static::$responseMode = static::shiftPath();
            if (in_array(static::$responseMode, ['json','jsonp'])) {
                if (!static::checkAPIAccess()) {
                    return static::throwAPIUnAuthorizedError();
                }
            }
        }

        return static::handleRecordsRequest();
    }
196957
public function getClient() {
		if ( $this->client === null ) {
			$this->client = $this->newClient();
		}
		return $this->client;
	}
355771
public function getClient()
    {
        if (!$this->client instanceof Client) {
            $this->client = new Client([
                "cookies" => true
            ]);
        }
        return $this->client;
    }
661892
public static function find()
    {
        try {
            $client = static::findOneByType(HttpClient::class);
        } catch (DiscoveryFailedException $e) {
            throw new NotFoundException(
                'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".',
                0,
                $e
            );
        }

        return static::instantiateClass($client);
    }
728862
def handler(self):
        """"""
        if self._handler is None:
            self._handler = self.HTTPSClientAuthHandler(key=self._keyfile,
                                                        cert=self._certificatefile)
        return self._handler
987992
protected function getClientUserAgent()
    {
        if ($this->requestStack->getCurrentRequest() === null) {
            throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__));
        }

        return $this->requestStack->getCurrentRequest()->server->get('HTTP_USER_AGENT');
    }