當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。