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


PHP Requests::head方法代码示例

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


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

示例1: _checkDownloads

 protected function _checkDownloads()
 {
     $this->log('start to check downloads');
     $failedChecks = array();
     foreach ($this->_downloadList as $downloadId => $url) {
         try {
             $this->log('check %s', $url);
             $response = \Requests::head($url);
             if (!$response->success) {
                 $failedChecks[$downloadId] = 'unknown reason';
             }
         } catch (\Exception $e) {
             $failedChecks[$downloadId] = $e->getMessage();
         }
     }
     $message = new \SAP\Daemon\Message\Download\CheckResult(array('failedChecks' => $failedChecks));
     $this->log('send message to worker');
     $zmsg = new \ZMQ\Zmsg($this->_socketToWorker);
     $zmsg->body_set(serialize($message));
     $zmsg->send();
     $this->log('finished downloads-check');
     return $failedChecks;
 }
开发者ID:sgraebner,项目名称:tp,代码行数:23,代码来源:Downloader.php

示例2: testHEAD

 public function testHEAD()
 {
     $request = Requests::head(httpbin('/get'), array(), $this->getOptions());
     $this->assertEquals(200, $request->status_code);
     $this->assertEquals('', $request->body);
 }
开发者ID:majinhui04,项目名称:pretty,代码行数:6,代码来源:Base.php

示例3: testSNISupport

 /**
  * Test that the transport supports Server Name Indication with HTTPS
  *
  * feelingrestful.com (owned by hmn.md and used with permission) points to
  * CloudFlare, and will fail if SNI isn't sent.
  */
 public function testSNISupport()
 {
     if ($this->skip_https) {
         $this->markTestSkipped('SSL support is not available.');
         return;
     }
     $request = Requests::head('https://feelingrestful.com/', array(), $this->getOptions());
     $this->assertEquals(200, $request->status_code);
 }
开发者ID:rmccue,项目名称:requests,代码行数:15,代码来源:Base.php

示例4: validId

 /**
  * Check if a media id is valid.
  *
  * @param  string $id Id to check against the oembed stream.
  *
  * @return boolean    TRUE if id is valid, FALSE otherwise. Throws errors
  *                    on invalid ids.
  */
 protected function validId($id)
 {
     $endpoint = $this->config->get('endpoint', '');
     $endpoint = $this->format($endpoint, ['{:id}' => $id]);
     if (!$id || !$endpoint) {
         return false;
     }
     $response = \Requests::head($endpoint);
     // If a head request fails, try to send a get request
     if ($response->status_code != 200) {
         $response = \Requests::get($endpoint);
     }
     if ($response->status_code == 401) {
         throw new \Exception('Embedding has been disabled for this media.');
     } elseif ($response->status_code == 404) {
         throw new \Exception('The media ID was not found.');
     } elseif ($response->status_code == 501) {
         throw new \Exception('Media informations can not be retrieved.');
     } elseif ($response->status_code != 200) {
         throw new \Exception('The media ID is invalid or the media was deleted.');
     } elseif (!$response->success) {
         $response->throw_for_status();
     }
     return true;
 }
开发者ID:ulilu,项目名称:grav-toctoc,代码行数:33,代码来源:OEmbed.php


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