当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getDefaultOption方法代码示例

本文整理汇总了PHP中GuzzleHttp\Client::getDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getDefaultOption方法的具体用法?PHP Client::getDefaultOption怎么用?PHP Client::getDefaultOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Client的用法示例。


在下文中一共展示了Client::getDefaultOption方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getClient

 /**
  * Get a configured client, creating one if one hasn't been set by
  * setClient().
  *
  * @return Client
  */
 public function getClient()
 {
     if (!$this->client) {
         $this->client = new Client();
         $headers = $this->client->getDefaultOption('headers');
         $headers['User-Agent'] = 'PkpPlnBot 1.0; http://pkp.sfu.ca';
         $this->client->setDefaultOption('headers', $headers);
     }
     return $this->client;
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:16,代码来源:HarvestCommand.php

示例2: wait

 /**
  * Wait for a container to finish
  *
  * @param \Docker\Container $container
  * @param integer|null      $timeout
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return \Docker\Manager\ContainerManager
  */
 public function wait(Container $container, $timeout = null)
 {
     $response = $this->client->post(['/containers/{id}/wait', ['id' => $container->getId()]], ['timeout' => null === $timeout ? $this->client->getDefaultOption('timeout') : $timeout]);
     if ($response->getStatusCode() !== "200") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     $container->setExitCode($response->json()['StatusCode']);
     $this->inspect($container);
     return $this;
 }
开发者ID:ramal-ratne,项目名称:docker-php,代码行数:20,代码来源:ContainerManager.php

示例3: testAuthenticateClient

 /**
  * @param array $credentials
  * @dataProvider credentialsProvider
  */
 public function testAuthenticateClient($credentials)
 {
     $client = new Client();
     $auth = new Basic($credentials);
     $auth->authenticateClient(new RestClient($client));
     self::assertEquals(['test', 'pass'], $client->getDefaultOption('auth'));
     $request = $client->createRequest('GET', '/');
     self::assertArrayHasKey('Authorization', $request->getHeaders());
     self::assertEquals(['Basic dGVzdDpwYXNz'], $request->getHeaders()['Authorization']);
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:14,代码来源:BasicTest.php

示例4: request

 /**
  * @param $capability
  * @param array $options
  * @throws Exceptions\CapabilityUnavailable
  * @throws Exceptions\RETSException
  * @return \GuzzleHttp\Message\ResponseInterface
  */
 protected function request($capability, $options = [])
 {
     $url = $this->capabilities->get($capability);
     if (!$url) {
         throw new CapabilityUnavailable("'{$capability}' tried but no valid endpoint was found.  Did you forget to Login()?");
     }
     if (!array_key_exists('headers', $options)) {
         $options['headers'] = [];
     }
     // Guzzle 5 changed the order that headers are added to the request, so we'll do this manually
     $options['headers'] = array_merge($this->client->getDefaultOption('headers'), $options['headers']);
     // user-agent authentication
     if ($this->configuration->getUserAgentPassword()) {
         $ua_digest = $this->configuration->userAgentDigestHash($this);
         $options['headers'] = array_merge($options['headers'], ['RETS-UA-Authorization' => 'Digest ' . $ua_digest]);
     }
     $options = array_merge($options, ['cookies' => $this->cookie_jar]);
     $this->debug("Sending HTTP Request for {$url} ({$capability})", $options);
     if (array_key_exists('query', $options)) {
         $this->last_request_url = $url . '?' . \http_build_query($options['query']);
     } else {
         $this->last_request_url = $url;
     }
     /** @var \GuzzleHttp\Message\ResponseInterface $response */
     if ($this->configuration->readOption('use_post_method')) {
         $this->debug('Using POST method per use_post_method option');
         $query = array_key_exists('query', $options) ? $options['query'] : null;
         $response = $this->client->post($url, array_merge($options, ['body' => $query]));
     } else {
         $response = $this->client->get($url, $options);
     }
     $this->last_response = $response;
     $cookie = $response->getHeader('Set-Cookie');
     if ($cookie) {
         if (preg_match('/RETS-Session-ID\\=(.*?)(\\;|\\s+|$)/', $cookie, $matches)) {
             $this->rets_session_id = $matches[1];
         }
     }
     if ($response->getHeader('Content-Type') == 'text/xml' and $capability != 'GetObject') {
         $xml = $response->xml();
         if ($xml and isset($xml['ReplyCode'])) {
             $rc = (string) $xml['ReplyCode'];
             // 20201 - No records found - not exception worthy in my mind
             if ($rc != "0" and $rc != "20201") {
                 throw new RETSException($xml['ReplyText'], (int) $xml['ReplyCode']);
             }
         }
     }
     $this->debug('Response: HTTP ' . $response->getStatusCode());
     return $response;
 }
开发者ID:jamesmalin,项目名称:PHRETS,代码行数:58,代码来源:Session.php

示例5: testAuthenticateClient

 public function testAuthenticateClient()
 {
     $client = new Client();
     $restClient = new RestClient($client);
     $auth = new OAuth10(['oauth_api' => ['credentials' => ['#data' => '{"oauth_token": "token", "oauth_token_secret": "token_secret"}', 'appKey' => 'aaa', '#appSecret' => 'bbb']]]);
     $auth->authenticateClient($restClient);
     self::assertEquals('oauth', $client->getDefaultOption('auth'));
     $request = $restClient->createRequest(['endpoint' => '/']);
     $mock = new Mock([new Response(200, [], Stream::factory('{}'))]);
     $client->getEmitter()->attach($mock);
     $history = new History();
     $client->getEmitter()->attach($history);
     $restClient->download($request);
     $authHeader = $history->getLastRequest()->getHeaders()['Authorization'][0];
     self::assertRegexp('/^OAuth oauth_consumer_key="aaa", oauth_nonce="([0-9a-zA-Z]*)", oauth_signature="([0-9a-zA-Z%]*)", oauth_signature_method="HMAC-SHA1", oauth_timestamp="([0-9]{10})", oauth_token="token", oauth_version="1.0"$/', $authHeader);
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:16,代码来源:OAuth10Test.php

示例6: testUsesProxyEnvironmentVariables

 public function testUsesProxyEnvironmentVariables()
 {
     $client = new Client();
     $this->assertNull($client->getDefaultOption('proxy'));
     putenv('HTTP_PROXY=127.0.0.1');
     $client = new Client();
     $this->assertEquals(['http' => '127.0.0.1'], $client->getDefaultOption('proxy'));
     putenv('HTTPS_PROXY=127.0.0.2');
     $client = new Client();
     $this->assertEquals(['http' => '127.0.0.1', 'https' => '127.0.0.2'], $client->getDefaultOption('proxy'));
     putenv('HTTP_PROXY=');
     putenv('HTTPS_PROXY=');
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:13,代码来源:ClientTest.php

示例7: removeToken

 /**
  * Remove the token for the given user in storage.
  *
  * @return void
  */
 public function removeToken()
 {
     $this->client->getDefaultOption('cookies')->clear();
 }
开发者ID:TutorsysteemPantarijn,项目名称:Tutor_inschrijven,代码行数:9,代码来源:ElegantUserProvider.php

示例8: getRequestOption

 /**
  * Returns the specified request option or all options if none specified.
  *
  * @param null $keyOrPath
  *
  * @return array|mixed|null
  */
 public function getRequestOption($keyOrPath = null)
 {
     return $this->guzzleClient->getDefaultOption($keyOrPath);
 }
开发者ID:JoelESvensson,项目名称:bsd-api-php,代码行数:11,代码来源:Client.php

示例9: testUsesProxyEnvironmentVariables

 public function testUsesProxyEnvironmentVariables()
 {
     $http = isset($_SERVER['HTTP_PROXY']) ? $_SERVER['HTTP_PROXY'] : null;
     $https = isset($_SERVER['HTTPS_PROXY']) ? $_SERVER['HTTPS_PROXY'] : null;
     unset($_SERVER['HTTP_PROXY']);
     unset($_SERVER['HTTPS_PROXY']);
     $client = new Client();
     $this->assertNull($client->getDefaultOption('proxy'));
     $_SERVER['HTTP_PROXY'] = '127.0.0.1';
     $client = new Client();
     $this->assertEquals(['http' => '127.0.0.1'], $client->getDefaultOption('proxy'));
     $_SERVER['HTTPS_PROXY'] = '127.0.0.2';
     $client = new Client();
     $this->assertEquals(['http' => '127.0.0.1', 'https' => '127.0.0.2'], $client->getDefaultOption('proxy'));
     $_SERVER['HTTP_PROXY'] = $http;
     $_SERVER['HTTPS_PROXY'] = $https;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:17,代码来源:ClientTest.php

示例10: getDefaultOptions

 public function getDefaultOptions()
 {
     return $this->client->getDefaultOption();
 }
开发者ID:canaltp,项目名称:abstract-guzzle,代码行数:4,代码来源:Guzzle5.php

示例11: copyClientDefaults

 /**
  * @param Client $client
  */
 protected function copyClientDefaults(Client $client)
 {
     $this->request->setUrl($client->getBaseUrl() . $this->request->getUrl());
     $this->request->addHeaders($client->getDefaultOption('headers'));
 }
开发者ID:mahsanamin,项目名称:box-php-sdk,代码行数:8,代码来源:AbstractCommand.php

示例12: prepareQuery

 /**
  * Prepares the query with the default parameters
  *
  * @param array $options
  *
  * @return array
  */
 private function prepareQuery($options = [])
 {
     return array_merge($this->client->getDefaultOption('query'), $options);
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:11,代码来源:ApiClient.php

示例13: testAuthHeaderSet

 public function testAuthHeaderSet()
 {
     $api = new API('1234', '4321', $this->client);
     $headers = $this->client->getDefaultOption('headers');
     $this->assertEquals('Bearer 1234 4321', $headers['Auth']);
 }
开发者ID:wondernetwork,项目名称:wiuphp,代码行数:6,代码来源:APITest.php


注:本文中的GuzzleHttp\Client::getDefaultOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。