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


PHP RequestInterface::getHeader方法代码示例

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


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

示例1: fromIncomingResponse

 /**
  * @param RequestInterface $originalRequest
  * @param ResponseInterface|null $response
  *
  * @return Span
  */
 public function fromIncomingResponse(RequestInterface $originalRequest, ResponseInterface $response = null)
 {
     $span = $originalRequest->getHeader('X-B3-SpanId');
     $trace = $originalRequest->getHeader('X-B3-TraceId');
     if (empty($span) || empty($trace)) {
         throw new \InvalidArgumentException('Unable to find the original request properties');
     }
     return new Span(Identifier::fromString($span), $this->getName($originalRequest), Identifier::fromString($trace), [new Annotation(Annotation::CLIENT_RECEIVE, $this->clock->microseconds(), $this->endpointResolver->resolve())], [new BinaryAnnotation('http.status', $response !== null ? $response->getStatusCode() : 0, BinaryAnnotation::TYPE_INTEGER_16)]);
 }
开发者ID:sroze,项目名称:tolerance,代码行数:15,代码来源:GuzzleMessageSpanFactory.php

示例2: createCanonicalizedString

 private function createCanonicalizedString(RequestInterface $request, $expires = null)
 {
     $buffer = $request->getMethod() . "\n";
     // Add the interesting headers
     foreach ($this->signableHeaders as $header) {
         $buffer .= $request->getHeader($header) . "\n";
     }
     $date = $expires ?: $request->getHeader('date');
     $buffer .= "{$date}\n" . $this->createCanonicalizedAmzHeaders($request) . $this->createCanonicalizedResource($request);
     return $buffer;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:11,代码来源:S3Signature.php

示例3: applyBody

 private function applyBody(RequestInterface $request, array &$options)
 {
     if ($request->hasHeader('Content-Length')) {
         $size = (int) $request->getHeader('Content-Length');
     } else {
         $size = null;
     }
     $request->getBody()->seek(0);
     // You can send the body as a string using curl's CURLOPT_POSTFIELDS
     if ($size !== null && $size < 32768 || isset($request->getConfig()['curl']['body_as_string'])) {
         $options[CURLOPT_POSTFIELDS] = $request->getBody()->getContents();
         // Don't duplicate the Content-Length header
         $this->removeHeader('Content-Length', $options);
         $this->removeHeader('Transfer-Encoding', $options);
     } else {
         $options[CURLOPT_UPLOAD] = true;
         // Let cURL handle setting the Content-Length header
         if ($size !== null) {
             $options[CURLOPT_INFILESIZE] = $size;
             $this->removeHeader('Content-Length', $options);
         }
     }
     // If the Expect header is not present, prevent curl from adding it
     if (!$request->hasHeader('Expect')) {
         $options[CURLOPT_HTTPHEADER][] = 'Expect:';
     }
 }
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:27,代码来源:CurlFactory.php

示例4: assertAuthorization

 /**
  * Asserts that the authorization header is correct.
  *
  * @param RequestInterface $request Request to test
  *
  * @return void
  */
 protected function assertAuthorization(RequestInterface $request)
 {
     list($alg, $digest) = explode(' ', $request->getHeader('Authorization'));
     $this->assertEquals('Basic', $alg);
     $expected = self::MERCHANT_ID . ':' . self::SHARED_SECRET;
     $this->assertEquals($expected, base64_decode($digest));
 }
开发者ID:NoviumDesign,项目名称:polefitness,代码行数:14,代码来源:ResourceTestCase.php

示例5: isRequestAuthorized

 /**
  * @param RequestInterface $httpRequest The HTTP request before it is sent.
  * @return bool false if the request needs to be authorized
  */
 private function isRequestAuthorized(RequestInterface $httpRequest)
 {
     $authorization = trim($httpRequest->getHeader('Authorization'));
     if (!$authorization) {
         return false;
     } else {
         return strpos($authorization, 'Basic') === 0;
     }
 }
开发者ID:finix-payments,项目名称:processing-php-client,代码行数:13,代码来源:BasicAuthentication.php

示例6: formatBody

 /**
  * @param RequestInterface|ResponseInterface $message
  * @return string
  */
 protected function formatBody($message)
 {
     $header = $message->getHeader('Content-Type');
     if (JsonStringFormatter::isJsonHeader($header)) {
         $formatter = new JsonStringFormatter();
         return $formatter->format($message->getBody());
     } elseif (XmlStringFormatter::isXmlHeader($header)) {
         $formatter = new XmlStringFormatter();
         return $formatter->format($message->getBody());
     }
     $factory = new StringFactoryFormatter();
     return $factory->format($message->getBody());
 }
开发者ID:glooby,项目名称:debug-bundle,代码行数:17,代码来源:AbstractMessageFormatter.php

示例7: getRequestCookieValues

 private function getRequestCookieValues(HttpRequest $request)
 {
     if (!$request->hasHeader('Cookie')) {
         return [];
     }
     $cookieStrings = explode(';', $request->getHeader('Cookie'));
     $values = [];
     foreach ($cookieStrings as $cookieString) {
         $cookieString = trim($cookieString);
         $currentValues = explode('=', $cookieString);
         $values[$currentValues[0]] = $currentValues[1];
     }
     return $values;
 }
开发者ID:webignition,项目名称:url-health-checker,代码行数:14,代码来源:ConfiguredCookiesTest.php

示例8: add_decode_content

 private function add_decode_content(RequestInterface $request, RequestMediator $mediator, &$options, $value)
 {
     if (!$request->hasHeader('Accept-Encoding')) {
         $options[CURLOPT_ENCODING] = '';
         // Don't let curl send the header over the wire
         $options[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
     } else {
         $options[CURLOPT_ENCODING] = $request->getHeader('Accept-Encoding');
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:10,代码来源:CurlFactory.php

示例9: addPostData

 /**
  * Apply POST fields and files to a request to attempt to give an accurate
  * representation.
  *
  * @param RequestInterface $request Request to update
  * @param array            $body    Body to apply
  */
 protected function addPostData(RequestInterface $request, array $body)
 {
     static $fields = ['string' => true, 'array' => true, 'NULL' => true, 'boolean' => true, 'double' => true, 'integer' => true];
     $post = new PostBody();
     foreach ($body as $key => $value) {
         if (isset($fields[gettype($value)])) {
             $post->setField($key, $value);
         } elseif ($value instanceof PostFileInterface) {
             $post->addFile($value);
         } else {
             $post->addFile(new PostFile($key, $value));
         }
     }
     if ($request->getHeader('Content-Type') == 'multipart/form-data') {
         $post->forceMultipartUpload(true);
     }
     $request->setBody($post);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:25,代码来源:MessageFactory.php

示例10: createStreamResource

 private function createStreamResource(RequestInterface $request, array $options, $context, &$http_response_header)
 {
     $url = $request->getUrl();
     // Add automatic gzip decompression
     if (strpos($request->getHeader('Accept-Encoding'), 'gzip') !== false) {
         $url = 'compress.zlib://' . $url;
     }
     return $this->createResource(function () use($url, &$http_response_header, $context) {
         if (false === strpos($url, 'http')) {
             trigger_error("URL is invalid: {$url}", E_USER_WARNING);
             return null;
         }
         return fopen($url, 'r', null, $context);
     }, $request, $options);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:15,代码来源:StreamAdapter.php

示例11: isJson

 private static function isJson(RequestInterface $request)
 {
     return preg_match('#^application/json#', $request->getHeader('Content-Type'));
 }
开发者ID:lezhnev74,项目名称:GuzzleHttpMock,代码行数:4,代码来源:RequestChecker.php

示例12: getCacheKey

 /**
  * Hash a request URL into a string that returns cache metadata.
  *
  * @param RequestInterface $request The Request to generate the cache key
  *                                  for.
  * @param array            $vary    (optional) An array of headers to vary
  *                                  the cache key by.
  *
  * @return string
  */
 private function getCacheKey(RequestInterface $request, array $vary = [])
 {
     $key = $request->getMethod() . ' ' . $request->getUrl();
     // If Vary headers have been passed in, fetch each header and add it to
     // the cache key.
     foreach ($vary as $header) {
         $key .= " {$header}: " . $request->getHeader($header);
     }
     return $this->keyPrefix . md5($key);
 }
开发者ID:thomaschaaf,项目名称:cache-subscriber,代码行数:20,代码来源:CacheStorage.php

示例13: getPayload

 protected function getPayload(RequestInterface $request)
 {
     // Calculate the request signature payload
     if ($request->hasHeader('x-amz-content-sha256')) {
         // Handle streaming operations (e.g. Glacier.UploadArchive)
         return (string) $request->getHeader('x-amz-content-sha256');
     }
     if ($body = $request->getBody()) {
         if (!$body->isSeekable()) {
             throw new CouldNotCreateChecksumException('sha256');
         }
         return Utils::hash($body, 'sha256');
     }
     return self::EMPTY_PAYLOAD;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:15,代码来源:SignatureV4.php


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