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


PHP Response::getHeader方法代码示例

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


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

示例1: rev

 public function rev(Response $response)
 {
     if ($response->isSuccessful()) {
         return $this->decode($response->getHeader('Etag'));
     }
     throw new RugException('not_found', 'The specified document or revision cannot be found or has been deleted');
 }
开发者ID:o100ja,项目名称:rug,代码行数:7,代码来源:AbstractDocumentParser.php

示例2: processSetCookieHeaders

 /**
  * Processes Set-Cookie headers from a request/response pair.
  * 
  * @param Message\Request  $request  A request object
  * @param Message\Response $response A response object
  */
 public function processSetCookieHeaders(Message\Request $request, Message\Response $response)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $header) {
         $cookie = new Cookie();
         $cookie->fromSetCookieHeader($header, parse_url($request->getHost(), PHP_URL_HOST));
         $this->addCookie($cookie);
     }
 }
开发者ID:philip,项目名称:Buzz,代码行数:14,代码来源:Jar.php

示例3: assertHttpResponseHasHeader

 protected function assertHttpResponseHasHeader(HttpResponse $response, $header, $expectedValue = null)
 {
     $headerValue = $response->getHeader($header);
     self::assertNotNull($headerValue, "Failed asserting that response has a {$header} header");
     if ($expectedValue !== null) {
         self::assertEquals($expectedValue, $headerValue);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:TestCase.php

示例4: handleResponseAuthHeader

 /**
  * @param \Buzz\Message\Response $response
  */
 private function handleResponseAuthHeader(\Buzz\Message\Response $response)
 {
     $token = $response->getHeader('Update-Client-Auth');
     if ($token) {
         $this->client->setAuthToken($token);
         $this->setTokenToCache($token);
     }
 }
开发者ID:rgies,项目名称:dsp,代码行数:11,代码来源:ClientAuthManagerWrapper.php

示例5: __construct

 /**
  * @param string|null $message
  */
 public function __construct(RequestInterface $request, Response $response, $message = null)
 {
     $this->request = $request;
     $this->response = $response;
     if ($message === null) {
         $curlError = $response->getHeader('X-Curl-Error-Result');
         $message = sprintf('HTTP %s request to "%s%s" failed: %d - "%s".', $request->getMethod(), $request->getHost(), $request->getResource(), $curlError ?: $response->getStatusCode(), $curlError ? curl_strerror($curlError) : $response->getReasonPhrase());
     }
     parent::__construct($message);
 }
开发者ID:vaniocz,项目名称:VanioBuzzBundle,代码行数:13,代码来源:RequestFailedException.php

示例6: isExpired

 /**
  * @param Response $response
  * @param int $minFresh
  * @return bool
  */
 public function isExpired(Response $response, $minFresh = 5)
 {
     $expires = $response->getHeader('expires');
     if ($expires !== null) {
         $parsedExpires = strtotime($expires);
         if ($parsedExpires === false || time() + $minFresh > $parsedExpires) {
             return true;
         }
     }
     return false;
 }
开发者ID:ivoba,项目名称:buzzle,代码行数:16,代码来源:CacheValidator.php

示例7: decompressContent

 private function decompressContent(\Buzz\Message\Response $response)
 {
     if (!($content_encoding = $response->getHeader('Content-Encoding'))) {
         return;
     }
     $content = $response->getContent();
     if (strpos($content_encoding, 'deflate') !== false) {
         $content = gzuncompress($content);
     }
     if (strpos($content_encoding, 'gzip') !== false) {
         $content = gzinflate(substr($content, 10));
     }
     $response->setContent($content);
 }
开发者ID:KaRpIkS,项目名称:torrent-announcer,代码行数:14,代码来源:Request.php

示例8: getPagination

 protected static function getPagination(Response $response)
 {
     $header = $response->getHeader('Link');
     if (empty($header)) {
         return;
     }
     $pagination = [];
     foreach (explode(',', $header) as $link) {
         preg_match('/<(.*)>; rel="(.*)"/i', trim($link, ','), $match);
         if (3 === count($match)) {
             $pagination[$match[2]] = $match[1];
         }
     }
     return $pagination;
 }
开发者ID:gushphp,项目名称:gush,代码行数:15,代码来源:GitLabAdapter.php

示例9: assertHttpResponseDeletesSessionCookie

 private static function assertHttpResponseDeletesSessionCookie($session, Response $response)
 {
     self::assertStringStartsWith("{$session->name}=deleted;", $response->getHeader('set-cookie'));
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:4,代码来源:SessionTest.php

示例10: validateResponse

 /**
  * @param  Response $response
  * @param  string                $method
  * @param  array                 $arguments
  * @return \stdClass
  * @throws \RuntimeException
  */
 protected function validateResponse($response, $method, $arguments)
 {
     if (!in_array($response->getStatusCode(), array(200, 401, 409))) {
         throw new \RuntimeException('Unexpected response received from Transmission');
     }
     if ($response->getStatusCode() == 401) {
         throw new \RuntimeException('Access to Transmission requires authentication');
     }
     if ($response->getStatusCode() == 409) {
         $this->setToken($response->getHeader(self::TOKEN_HEADER));
         return $this->call($method, $arguments);
     }
     return json_decode($response->getContent());
 }
开发者ID:afk11,项目名称:transmission-php,代码行数:21,代码来源:Client.php

示例11: mimeTypeByResponse

 /**
  * @param Response $response
  *
  * @return string|null
  */
 protected function mimeTypeByResponse(Response $response)
 {
     $mimeType = $response->getHeader('Content-Type', false);
     if (count($mimeType) > 0) {
         $mimeType = array_pop($mimeType);
         $mimeType = explode(';', $mimeType);
         $mimeType = trim(array_shift($mimeType));
         if ('text/plain' !== strtolower($mimeType)) {
             return $mimeType;
         }
     }
     return null;
 }
开发者ID:eloquent,项目名称:schemer,代码行数:18,代码来源:HttpLoader.php

示例12: sendCookiesFromResponse

 /**
  * Send cookies to client from a contao response object
  *
  * @param Response $response
  * @return bool
  */
 protected function sendCookiesFromResponse(Response $response)
 {
     // Set cookies from the contao response
     if ($response->getHeader('set-cookie')) {
         $delimiter = ' || ';
         $cookies = explode($delimiter, $response->getHeader('set-cookie', $delimiter));
         foreach ($cookies as $cookie) {
             // The second param has to be false otherwise other cookies like from phpbb itself are replaced
             header('Set-Cookie: ' . $cookie, false);
         }
         // The following won't work because the expire value is not an int and conversion something like
         // 16-Jan-2016 18:07:35 GMT to an int is really unnecessary overhead
         // although it's looks cleaner at first like above solution
         // $cookieJar = new CookieJar();
         // $cookieJar->processSetCookieHeaders($browser->getLastRequest(), $response);
         // foreach($cookieJar->getCookies() as $cookie) {
         //      setcookie($cookie->getName(), $cookie->getValue(), $cookie->getAttribute('expires'), $cookie->getAttribute('path'), $cookie->getAttribute('domain'), $cookie->getAttribute('secure'),$cookie->getAttribute('httponly'));
         // }                  }
     }
 }
开发者ID:ctsmedia,项目名称:contao-phpbb-bridge-bundle,代码行数:26,代码来源:Connector.php

示例13: isJsonResponse

 /**
  * Checks if we had a successfull response with Json content in it
  *
  * @param Response $response
  * @return bool
  */
 protected function isJsonResponse(Response $response)
 {
     return $response->getStatusCode() == 200 && $response->getHeader('content-type') == 'application/json';
 }
开发者ID:ctsmedia,项目名称:contao-phpbb-bridge-bundle,代码行数:10,代码来源:Connector.php

示例14: collectLocations

 /**
  * @Then /^save new item location as "([^"]*)"$/
  * @param string $location
  *
  * @return boolean
  */
 public function collectLocations($locationIndex)
 {
     $this->response = $this->client->getLastResponse();
     $this->locations[$locationIndex] = $this->response->getHeader('X-Location');
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:11,代码来源:RestContext.php

示例15: getSessionIdFromResponse

 protected function getSessionIdFromResponse(Response $response)
 {
     $statusCode = $response->getStatusCode();
     if ($statusCode === 200) {
         $content = json_decode($response->getContent(), true);
         if ($content['status'] !== 0) {
             throw new LibraryException(sprintf('Expected status 0, got "%s".', $content['status']));
         }
         return $content['sessionId'];
     }
     if ($statusCode !== 302) {
         echo $response->getContent();
         throw new LibraryException(sprintf('The response should be a redirection, response code from server was "%s"', $statusCode));
     }
     $location = $response->getHeader('Location');
     if (!preg_match('#/session/([0-9a-f\\-]+)?#', $location, $vars)) {
         throw new LibraryException(sprintf('The Location should end with /session/<session-id> (location returned: %s)', $location));
     }
     return $vars[1];
 }
开发者ID:alexandresalome,项目名称:php-webdriver,代码行数:20,代码来源:Client.php


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