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


PHP RequestInterface::hasHeader方法代码示例

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


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

示例1: signRequest

 /**
  * {@inheritdoc}
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Add a date header if one is not set
     if (!$request->hasHeader('date') && !$request->hasHeader('x-amz-date')) {
         $request->setHeader('Date', gmdate(DateFormat::RFC2822));
     }
     $stringToSign = (string) $request->getHeader('Date') ?: (string) $request->getHeader('x-amz-date');
     $request->getParams()->set('aws.string_to_sign', $stringToSign);
     $request->setHeader('Authorization', 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials));
 }
开发者ID:risyasin,项目名称:webpagetest,代码行数:13,代码来源:CloudFrontSignature.php

示例2: signRequest

 /**
  * {@inheritdoc}
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Add the security token header if one is being used by the credentials
     if ($token = $credentials->getSecurityToken()) {
         $request->setHeader('x-amz-security-token', $token);
     }
     // Add a date header if one is not set
     if (!$request->hasHeader('date') && !$request->hasHeader('x-amz-date')) {
         $request->setHeader('Date', gmdate(DateFormat::RFC2822));
     }
     $stringToSign = $this->createCanonicalizedString($request);
     $request->getParams()->set('aws.string_to_sign', $stringToSign);
     $request->setHeader('Authorization', 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials));
 }
开发者ID:noahkim,项目名称:kowop,代码行数:17,代码来源:S3Signature.php

示例3: after

public function after(CommandInterface $command, RequestInterface $request)
{
$xml = null;


 if (isset($this->data[$command])) {
$xml = $this->finishDocument($this->data[$command]);
unset($this->data[$command]);
} else {

 $operation = $command->getOperation();
if ($operation->getData('xmlAllowEmpty')) {
$xmlWriter = $this->createRootElement($operation);
$xml = $this->finishDocument($xmlWriter);
}
}

if ($xml) {

 if ($this->contentType && !$request->hasHeader('Content-Type')) {
$request->setHeader('Content-Type', $this->contentType);
}
$request->setBody($xml);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:25,代码来源:XmlVisitor.php

示例4: signRequest

 /**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     if ($request instanceof EntityEnclosingRequestInterface && $request->getBody() && !$request->hasHeader('x-amz-content-sha256')) {
         $request->setHeader('X-Amz-Content-Sha256', $this->getPresignedPayload($request));
     }
     parent::signRequest($request, $credentials);
 }
开发者ID:im286er,项目名称:ent,代码行数:10,代码来源:S3SignatureV4.php

示例5: signRequest

 /**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     if (!$request->hasHeader('x-amz-content-sha256')) {
         $request->setHeader('x-amz-content-sha256', $this->getPayload($request));
     }
     parent::signRequest($request, $credentials);
 }
开发者ID:nstanard,项目名称:webpagetest,代码行数:10,代码来源:S3SignatureV4.php

示例6: after

 public function after(CommandInterface $command, RequestInterface $request)
 {
     if (isset($this->data[$command])) {
         if ($this->jsonContentType && !$request->hasHeader('Content-Type')) {
             $request->setHeader('Content-Type', $this->jsonContentType);
         }
         $request->setBody(json_encode($this->data[$command]));
         unset($this->data[$command]);
     }
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:10,代码来源:JsonVisitor.php

示例7: signRequest

 /**
  * {@inheritdoc}
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Add a date header if one is not set
     if (!$request->hasHeader('date') && !$request->hasHeader('x-amz-date')) {
         $request->setHeader('Date', $this->getDateTime(DateFormat::RFC1123));
     }
     // Add the security token if one is present
     if ($credentials->getSecurityToken()) {
         $request->setHeader('x-amz-security-token', $credentials->getSecurityToken());
     }
     // Determine the string to sign
     $stringToSign = $request->getHeader('Date', true) ?: $request->getHeader('x-amz-date', true);
     $request->getParams()->set('aws.string_to_sign', $stringToSign);
     // Calculate the signature
     $signature = base64_encode(hash_hmac('sha256', $stringToSign, $credentials->getSecretKey(), true));
     // Add the authorization header to the request
     $headerFormat = 'AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s';
     $request->setHeader('X-Amzn-Authorization', sprintf($headerFormat, $credentials->getAccessKeyId(), $signature));
 }
开发者ID:cstuder,项目名称:nagios-plugins,代码行数:22,代码来源:SignatureV3Https.php

示例8: canCacheRequest

 public function canCacheRequest(RequestInterface $request)
 {
     if ($request->getMethod() != RequestInterface::GET && $request->getMethod() != RequestInterface::HEAD) {
         return false;
     }
     if ($request->hasHeader('Cache-Control') && $request->getHeader('Cache-Control')->hasDirective('no-store')) {
         return false;
     }
     return true;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:10,代码来源:DefaultCanCacheStrategy.php

示例9: after

 /**
  * {@inheritdoc}
  */
 public function after(CommandInterface $command, RequestInterface $request)
 {
     if (isset($this->data[$command])) {
         $request->setBody($this->data[$command]->asXML());
         unset($this->data[$command]);
         // Don't overwrite the Content-Type if one is set
         if ($this->contentType && !$request->hasHeader('Content-Type')) {
             $request->setHeader('Content-Type', $this->contentType);
         }
     }
 }
开发者ID:noahkim,项目名称:kowop,代码行数:14,代码来源:XmlVisitor.php

示例10: addDefaultContextOptions

 protected function addDefaultContextOptions(RequestInterface $request)
 {
     $this->setContextValue('http', 'method', $request->getMethod());
     $headers = $request->getHeaderLines();
     if (!$request->hasHeader('Connection')) {
         $headers[] = 'Connection: close';
     }
     $this->setContextValue('http', 'header', $headers);
     $this->setContextValue('http', 'protocol_version', $request->getProtocolVersion());
     $this->setContextValue('http', 'ignore_errors', true);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:11,代码来源:PhpStreamRequestFactory.php

示例11: after

 /**
  * {@inheritdoc}
  */
 public function after(CommandInterface $command, RequestInterface $request)
 {
     if (isset($this->data[$command])) {
         $json = $this->data[$command];
         unset($this->data[$command]);
         $request->setBody(json_encode($json));
         // Don't overwrite the Content-Type if one is set
         if ($this->jsonContentType && !$request->hasHeader('Content-Type')) {
             $request->setHeader('Content-Type', $this->jsonContentType);
         }
     }
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:15,代码来源:JsonVisitor.php

示例12: after

 public function after(CommandInterface $command, RequestInterface $request)
 {
     $xml = null;
     // If data was found that needs to be serialized, then do so
     if (isset($this->data[$command])) {
         $xml = $this->data[$command]->asXML();
         unset($this->data[$command]);
     } else {
         // Check if XML should always be sent for the command
         $operation = $command->getOperation();
         if ($operation->getData('xmlAllowEmpty')) {
             $xml = $this->createRootElement($operation)->asXML();
         }
     }
     if ($xml) {
         $request->setBody($xml);
         // Don't overwrite the Content-Type if one is set
         if ($this->contentType && !$request->hasHeader('Content-Type')) {
             $request->setHeader('Content-Type', $this->contentType);
         }
     }
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:22,代码来源:XmlVisitor.php

示例13: beforeSend

 /**
  * Prepare for sending
  *
  * @param RequestInterface $request Request to prepare
  * @throws \Exception on error preparing the request
  */
 protected function beforeSend(RequestInterface $request)
 {
     try {
         // Fix Content-Length and Transfer-Encoding collisions
         if ($request->hasHeader('Transfer-Encoding') && $request->hasHeader('Content-Length')) {
             $request->removeHeader('Transfer-Encoding');
         }
         $request->setState(RequestInterface::STATE_TRANSFER);
         $request->dispatch('request.before_send', array('request' => $request));
         if ($request->getState() != RequestInterface::STATE_TRANSFER) {
             // Requests might decide they don't need to be sent just before transfer (e.g. CachePlugin)
             $this->remove($request);
             if ($request->getState() == RequestInterface::STATE_COMPLETE) {
                 $this->successful[] = $request;
             }
         } else {
             // Add the request curl handle to the multi handle
             $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $this->createCurlHandle($request)->getHandle()));
         }
     } catch (\Exception $e) {
         // Queue the exception to be thrown when sent
         $this->removeErroredRequest($request, $e);
     }
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:30,代码来源:CurlMulti.php

示例14: hasHeader

 /**
  * @param string $name
  * @return bool
  */
 public function hasHeader($name)
 {
     return $this->request->hasHeader($name);
 }
开发者ID:99designs,项目名称:http-signatures-guzzle,代码行数:8,代码来源:Message.php

示例15: visit_headers

protected function visit_headers(RequestInterface $request, $value, $flags)
{
if (!is_array($value)) {
throw new InvalidArgumentException('headers value must be an array');
}

if ($flags & self::OPTIONS_AS_DEFAULTS) {

 foreach ($value as $key => $header) {
if (!$request->hasHeader($key)) {
$request->setHeader($key, $header);
}
}
} else {
$request->addHeaders($value);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:17,代码来源:RequestFactory.php


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