本文整理汇总了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;
}
示例2: testHEAD
public function testHEAD()
{
$request = Requests::head(httpbin('/get'), array(), $this->getOptions());
$this->assertEquals(200, $request->status_code);
$this->assertEquals('', $request->body);
}
示例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);
}
示例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;
}