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


PHP Client::head方法代码示例

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


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

示例1: __construct

 /**
  * MailTestCase.
  */
 public function __construct()
 {
     $this->mailcatcher = new \GuzzleHttp\Client(['base_uri' => 'http://localhost:1080']);
     if ($this->mailcatcher->head('/messages')->getStatusCode() !== 200) {
         throw new Exception('Install and boot up mailcatcher first. $ gem install mailcatcher && mailcatcher');
     }
 }
开发者ID:valdinei,项目名称:rest,代码行数:10,代码来源:MailTestCase.php

示例2: exists

 /**
  * Check if a gravatar exists.
  *
  * @param $email
  *
  * @return bool
  */
 public function exists($email)
 {
     $gravatar = $this->buildURL($email, 100, 404);
     try {
         $this->client->head($gravatar);
         return true;
     } catch (RequestException $e) {
         return false;
     }
 }
开发者ID:stayallive,项目名称:support,代码行数:17,代码来源:Gravatar.php

示例3: checkDependencies

 /**
  * @param  array $dependencies
  * @return array
  */
 private function checkDependencies(array $dependencies, DrupalStyle $io)
 {
     $this->site->loadLegacyFile('/core/modules/system/system.module');
     $localModules = array();
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         array_push($localModules, basename($module->subpath));
     }
     $checkDependencies = ['local_modules' => [], 'drupal_modules' => [], 'no_modules' => []];
     foreach ($dependencies as $module) {
         if (in_array($module, $localModules)) {
             $checkDependencies['local_modules'][] = $module;
         } else {
             try {
                 $response = $this->httpClient->head('https://www.drupal.org/project/' . $module);
                 $header_link = explode(';', $response->getHeader('link'));
                 if (empty($header_link[0])) {
                     $checkDependencies['no_modules'][] = $module;
                 } else {
                     $checkDependencies['drupal_modules'][] = $module;
                 }
             } catch (ClientException $e) {
                 $checkDependencies['no_modules'][] = $module;
             }
         }
     }
     return $checkDependencies;
 }
开发者ID:GDrupal,项目名称:DrupalConsole,代码行数:32,代码来源:ModuleCommand.php

示例4: head

 /**
  * @param string $uri
  * @param array $data
  * @param array $options
  * @param bool $api
  * @return $this;
  */
 public function head($uri, array $data = [], array $options = [], $api = true)
 {
     $uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
     $response = $this->client->head($uri, array_merge($options, ['body' => $data]));
     $this->setGuzzleResponse($response);
     return $this;
 }
开发者ID:someline,项目名称:rest-api-client,代码行数:14,代码来源:RestClient.php

示例5: assertFilesDownloadable

 /**
  * Checks that the given list of files return a 200 OK status code.
  *
  * @param \Behat\Gherkin\Node\TableNode $files
  *   The list of files that should be downloadable, relative to the base URL.
  *
  * @throws \Behat\Mink\Exception\ExpectationException
  *   Thrown when a file could not be downloaded.
  *
  * @Then the following files can be downloaded:
  */
 public function assertFilesDownloadable(TableNode $files)
 {
     $client = new Client();
     foreach ($files->getColumn(0) as $file) {
         if ($client->head($this->locatePath($file))->getStatusCode() != 200) {
             throw new ExpectationException("File {$file} could not be downloaded.");
         }
     }
 }
开发者ID:ec-europa,项目名称:platform-dev,代码行数:20,代码来源:MinkContext.php

示例6: linkIsValid

 /**
  * Before outputting custom links, it is validated to ensure that the user is not
  * directed off to a broken link. If a 404 is detected, it is hidden.
  *
  * @param $link The proposed link
  *
  * @return bool
  */
 private function linkIsValid($link)
 {
     $link = $this->docDomain . $link;
     try {
         $resp = $this->client->head($link);
     } catch (ClientException $e) {
     }
     return $resp->getStatusCode() < 400;
 }
开发者ID:boxrice007,项目名称:openstack,代码行数:17,代码来源:Builder.php

示例7: getUriHeaders

 /**
  * @param string $uri
  * @return ResponseInterface
  */
 public static function getUriHeaders($uri)
 {
     if (!Validation::isValidLink($uri)) {
         throw new InvalidUriException($uri . ' is not a valid link');
     }
     $httpClient = new Client();
     $resource = $httpClient->head($uri, ['allow_redirects' => true, 'connect_timeout' => 2, 'timeout' => 5]);
     unset($httpClient);
     return $resource;
 }
开发者ID:WildPHP,项目名称:api,代码行数:14,代码来源:Remote.php

示例8: getUriHeaders

 /**
  * @param string $uri
  * @return ResponseInterface
  */
 public static function getUriHeaders($uri)
 {
     if (!self::isValidLink($uri)) {
         throw new InvalidUriException($uri . ' is not a valid link');
     }
     $httpClient = new Client();
     $resource = $httpClient->head($uri);
     unset($httpClient);
     return $resource;
 }
开发者ID:Mkaysi,项目名称:Wild-IRC-Bot,代码行数:14,代码来源:Remote.php

示例9: examine

 /**
  * Checks if a string is spam or not
  *
  * @param   mixed   $data     string|array
  * @param   array   $options
  * @return  object
  */
 public function examine(array $data, array $options = array())
 {
     $path = '';
     $status = 0;
     $meta = array();
     if (isset($data['path']) && $data['path']) {
         $path = ltrim($data['path'], '/');
         $path = trim($path);
         $meta['field'] = $data['path'];
         $status = -1;
         if ($this->isLink($path)) {
             try {
                 $response = $this->client->head($path, ['exceptions' => false, 'timeout' => 10]);
                 $meta['code'] = $response->getStatusCode();
                 if ($response->getStatusCode() == 200) {
                     $status = 1;
                 }
             } catch (\Exception $e) {
                 $meta['error'] = $e->getMessage();
             }
         } else {
             $params = \Component::params('com_resources');
             $base = $params->get('uploadpath', '/site/resources');
             $base = PATH_APP . DS . trim($base, DS) . DS;
             if (is_dir($base . $path)) {
                 $meta['error'] = 'Path is a directory';
             }
             if (file_exists($base . $path)) {
                 $status = 1;
             }
         }
     }
     $result = new Result();
     $result->set(['scope_id' => $data['id'], 'status' => $status, 'notes' => json_encode($meta)]);
     return $result;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:43,代码来源:links.php

示例10: head

 /**
  * Sends a HEAD request
  * @param string $uri
  * @param array $options Array such as
  *              'headers' => [
  *                  'foo' => 'bar',
  *              ],
  *              'cookies' => ['
  *                  'foo' => 'bar',
  *              ],
  *              'allow_redirects' => [
  *                   'max'       => 10,  // allow at most 10 redirects.
  *                   'strict'    => true,     // use "strict" RFC compliant redirects.
  *                   'referer'   => true,     // add a Referer header
  *                   'protocols' => ['https'] // only allow https URLs
  *              ],
  *              'save_to' => '/path/to/file', // save to a file or a stream
  *              'verify' => true, // bool or string to CA file
  *              'debug' => true,
  *              'timeout' => 5,
  * @return Response
  * @throws \Exception If the request could not get completed
  */
 public function head($uri, $options = [])
 {
     $response = $this->client->head($uri, $options);
     return new Response($response);
 }
开发者ID:unrealbato,项目名称:core,代码行数:28,代码来源:client.php

示例11: request

 /**
  * This method make simple Requests using the GuzzleClient and disalbeds redirects to get the Location Header
  *
  * @see Client
  *
  * @param string $url The URL that will get requested
  * @return \Psr\Http\Message\ResponseInterface|\GuzzleHttp\Psr7\Stream
  */
 protected function request($url)
 {
     $client = new Client();
     return $client->head($url, ['allow_redirects' => false]);
 }
开发者ID:tzfrs,项目名称:urlextender,代码行数:13,代码来源:URLExtender.php

示例12: size

	/**
	 * Returns the video size raw or formatted to largest increment possible
	 *
	 * @param bool $raw
	 * @return string|int
	 */
	public function size( $raw = false )
	{
		if ( in_array( $this->domain(), array( 'youtube', 'youtu' ) ) ) {
			return 0;
		}

		static $cache				=	array();

		$id							=	$this->get( 'url' );

		if ( ! isset( $cache[$id] ) ) {
			$fileSize				=	0;

			if ( $this->exists() ) {
				try {
					$request		=	new GuzzleHttp\Client();

					$header			=	$request->head( $id );

					if ( ( $header !== false ) && ( $header->getStatusCode() == 200 ) ) {
						$fileSize	=	(int) $header->getHeader( 'Content-Length' );
					}
				} catch( Exception $e ) {}
			}

			$cache[$id]				=	$fileSize;
		}

		if ( ! $raw ) {
			return CBGroupJive::getFormattedFileSize( $cache[$id] );
		}

		return $cache[$id];
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:40,代码来源:VideoTable.php

示例13: testEmitsHeadersEventForHeadRequest

 public function testEmitsHeadersEventForHeadRequest()
 {
     Server::enqueue(["HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK"]);
     $ee = null;
     $client = new Client(['adapter' => new MultiAdapter(new MessageFactory())]);
     $client->head(Server::$url, ['events' => ['headers' => function (HeadersEvent $e) use(&$ee) {
         $ee = $e;
     }]]);
     $this->assertInstanceOf('GuzzleHttp\\Event\\HeadersEvent', $ee);
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:10,代码来源:RequestMediatorTest.php

示例14: head

 /**
  * Sends a HEAD request
  *
  * @param string $uri
  * @param array $options Array such as
  *              'headers' => [
  *                  'foo' => 'bar',
  *              ],
  *              'cookies' => ['
  *                  'foo' => 'bar',
  *              ],
  *              'allow_redirects' => [
  *                   'max'       => 10,  // allow at most 10 redirects.
  *                   'strict'    => true,     // use "strict" RFC compliant redirects.
  *                   'referer'   => true,     // add a Referer header
  *                   'protocols' => ['https'] // only allow https URLs
  *              ],
  *              'save_to' => '/path/to/file', // save to a file or a stream
  *              'verify' => true, // bool or string to CA file
  *              'debug' => true,
  *              'timeout' => 5,
  * @return Response
  * @throws \Exception If the request could not get completed
  */
 public function head($uri, $options = [])
 {
     $this->setDefaultOptions();
     $response = $this->client->head($uri, $options);
     return new Response($response);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:30,代码来源:Client.php

示例15: getMimetype

 /**
  * Get the mimetype of a file.
  *
  * @param string $path
  *
  * @return array|false
  */
 public function getMimetype($path)
 {
     $response = $this->httpClient->head($this->applyPathPrefix($path), ['headers' => ['X-Akamai-ACS-Action' => $this->getAcsActionHeaderValue('download')]]);
     $mimetype = $response->getHeader('Content-Type')[0];
     return ['mimetype' => $mimetype];
 }
开发者ID:akamai-open,项目名称:NetStorageKit-PHP,代码行数:13,代码来源:FileStoreAdapter.php


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