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


PHP Response::getHeader方法代码示例

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


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

示例1: testDeleteHeader

 public function testDeleteHeader()
 {
     $this->object->setHeader('Sample', 'value');
     $this->assertThat($this->object->getHeader('sample'), $this->equalTo('value'));
     $this->object->deleteHeader('Sample');
     $this->assertThat($this->object->getHeader('sample'), $this->equalTo(null));
 }
开发者ID:juraj-blahunka,项目名称:Bachelor-Thesis,代码行数:7,代码来源:ResponseTest.php

示例2: getLatestResponseHeaders

 /**
  * {@inheritdoc}
  */
 public function getLatestResponseHeaders()
 {
     if (null === $this->response) {
         return;
     }
     return ['reset' => (int) (string) $this->response->getHeader('RateLimit-Reset'), 'remaining' => (int) (string) $this->response->getHeader('RateLimit-Remaining'), 'limit' => (int) (string) $this->response->getHeader('RateLimit-Limit')];
 }
开发者ID:softr,项目名称:asaas-php-sdk,代码行数:10,代码来源:GuzzleHttpAdapter.php

示例3: matchModified

 /**
  * Returns whether a resource has been modified between two requests.
  *
  * @return bool
  */
 protected function matchModified()
 {
     $lastModified = $this->response->getHeader("Last-Modified");
     $modifiedSince = $this->request->getModifiedSince();
     if ($modifiedSince && $lastModified) {
         return strtotime($modifiedSince) >= strtotime($lastModified);
     }
     return false;
 }
开发者ID:rawebone,项目名称:wilson,代码行数:14,代码来源:Sender.php

示例4: redirect

 /**
  * redirect from response 3xx
  */
 protected function redirect()
 {
     $redirect_url = $this->response->getHeader("location");
     $curl = new static($redirect_url);
     if ($this->cookie_jar) {
         $curl->storeSession($this->cookie_jar);
     }
     $this->response = $curl->get();
     $this->redirect_urls[] = $redirect_url;
 }
开发者ID:rakit,项目名称:curl,代码行数:13,代码来源:Curl.php

示例5: testConstruct

 public function testConstruct()
 {
     $response = new Response(["test" => "value"], "php://memory", 201, "1.1");
     $this->assertInstanceOf('Psr\\Http\\Message\\StreamInterface', $response->getBody());
     $this->assertEquals(["test" => ["value"]], $response->getHeaders());
     $this->assertEquals("1.1", $response->getProtocolVersion());
     $this->assertEquals(["value"], $response->getHeader("test"));
     $this->assertEquals(201, $response->getStatusCode());
     $this->assertEquals("Created", $response->getReasonPhrase());
 }
开发者ID:fabyscore,项目名称:fabyscore-lib,代码行数:10,代码来源:ResponseTest.php

示例6: __construct

 public function __construct(Response $parent)
 {
     $status = $parent->getStatus();
     $convertToJson = false;
     $ok = self::statusIsOK($status);
     if ($ok) {
         $contentType = $parent->getHeader('Content-Type');
         if (!empty($contentType)) {
             $convertToJson = stristr($contentType, '/json') !== false;
         }
     }
     $bodyString = $parent->getBody();
     parent::__construct($convertToJson ? json_decode($bodyString) : $bodyString, $parent->getHeaders(), $status);
     $this->ok = $ok;
 }
开发者ID:jonasvr,项目名称:lockedornot,代码行数:15,代码来源:InfogramResponse.php

示例7: validateResponse

 /**
  * {@inheritdoc}
  */
 public function validateResponse(Request $request, Response $response) : bool
 {
     if (Response::SWITCHING_PROTOCOLS !== $response->getStatusCode()) {
         return false;
     }
     if ('upgrade' !== strtolower($response->getHeader('Connection'))) {
         return false;
     }
     if ('websocket' !== strtolower($response->getHeader('Upgrade'))) {
         return false;
     }
     $key = $request->getHeader('Sec-WebSocket-Key');
     if (!$response->hasHeader('Sec-WebSocket-Accept')) {
         return false;
     }
     return $this->responseKey($key) === $response->getHeader('Sec-WebSocket-Accept');
 }
开发者ID:icicleio,项目名称:websocket,代码行数:20,代码来源:Rfc6455Protocol.php

示例8: onReceive

 function onReceive($serv, $client_id, $from_id, $data)
 {
     $response = new Response();
     $response->body = json_encode(array(1, 2, 3));
     $this->server->getSwoole()->send($client_id, $response->getHeader() . $response->body);
     sleep(1);
     $this->server->getSwoole()->close($client_id);
     return;
     // //检测request data完整性
     // $ret = $this->checkData($client_id, $data);
     // switch($ret)
     // {
     //     //错误的请求
     //     case self::ST_ERROR;
     //         $this->server->close($client_id);
     //         return;
     //     //请求不完整,继续等待
     //     case self::ST_WAIT:
     //         return;
     //     default:
     //         break;
     // }
     // //完整的请求
     // //开始处理
     // $request = $this->requests[$client_id];
     // $info = $serv->connection_info($client_id);
     // $request->remote_ip = $info['remote_ip'];
     // $_SERVER['SWOOLE_CONNECTION_INFO'] = $info;
     // $this->parseRequest($request);
     // $request->fd = $client_id;
     // $this->currentRequest = $request;
     // if ($this->async)
     // {
     //     $this->onAsyncRequest($request);
     // }
     // else
     // {
     //     //处理请求,产生response对象
     //     $response = $this->onRequest($request);
     //     //发送response
     //     $this->response($request, $response);
     // }
     Console::output("onReceive");
 }
开发者ID:kenshin1983,项目名称:swoole_task,代码行数:44,代码来源:App.php

示例9: trim

 /**
  * @param Response $response
  */
 function __construct(Response $response)
 {
     $this->response = $response;
     if (($h = $response->getHeader("Content-Type", Header::class)) && $h->match("application/json", Header::MATCH_WORD) && ($failure = json_decode($response->getBody()))) {
         $message = $failure->message;
         if (isset($failure->errors)) {
             $this->errors = (array) $failure->errors;
         }
     } else {
         $message = trim($response->getBody()->toString());
     }
     if (!strlen($message)) {
         $message = $response->getTransferInfo("error");
     }
     if (!strlen($message)) {
         $message = $response->getResponseStatus();
     }
     parent::__construct($message, $response->getResponseCode(), null);
 }
开发者ID:m6w6,项目名称:seekat,代码行数:22,代码来源:RequestException.php

示例10: buildOutgoingResponse

 /**
  * {@inheritdoc}
  */
 public function buildOutgoingResponse(Response $response, Request $request = null, float $timeout = 0, bool $allowPersistent = false) : \Generator
 {
     if ('upgrade' === strtolower($response->getHeader('Connection'))) {
         return $response;
     }
     if ($allowPersistent && null !== $request && 'keep-alive' === strtolower($request->getHeader('Connection'))) {
         $response = $response->withHeader('Connection', 'keep-alive')->withHeader('Keep-Alive', sprintf('timeout=%d, max=%d', $this->keepAliveTimeout, $this->keepAliveMax));
     } else {
         $response = $response->withHeader('Connection', 'close');
     }
     $response = $response->withoutHeader('Content-Encoding');
     if ($this->compressionEnabled && null !== $request && $request->hasHeader('Accept-Encoding') && $response->hasHeader('Content-Type') && preg_match('/gzip|deflate/i', $request->getHeader('Accept-Encoding'), $matches)) {
         $encoding = strtolower($matches[0]);
         $contentType = $response->getHeader('Content-Type');
         foreach ($this->compressTypes as $pattern) {
             if (preg_match($pattern, $contentType)) {
                 $response = $response->withHeader('Content-Encoding', $encoding);
                 break;
             }
         }
     }
     return yield from $this->buildOutgoingStream($response, $timeout);
 }
开发者ID:icicleio,项目名称:http,代码行数:26,代码来源:Http1Builder.php

示例11: import

 /**
  * Import handler for the endpoint's underlying data
  *
  * \seekat\Call will call this when the request will have finished.
  *
  * @param Response $response
  * @return API self
  * @throws UnexpectedValueException
  * @throws RequestException
  * @throws \Exception
  */
 function import(Response $response) : API
 {
     $this->__log->info(__FUNCTION__ . ": " . $response->getInfo(), ["url" => (string) $this->__url]);
     if ($response->getResponseCode() >= 400) {
         $e = new RequestException($response);
         $this->__log->critical(__FUNCTION__ . ": " . $e->getMessage(), ["url" => (string) $this->__url]);
         throw $e;
     }
     if (!($type = $response->getHeader("Content-Type", Header::class))) {
         $e = new RequestException($response);
         $this->__log->error(__FUNCTION__ . ": Empty Content-Type -> " . $e->getMessage(), ["url" => (string) $this->__url]);
         throw $e;
     }
     try {
         $this->__type = new ContentType($type);
         $this->__data = $this->__type->parseBody($response->getBody());
         if ($link = $response->getHeader("Link", Header::class)) {
             $this->__links = new Links($link);
         }
     } catch (\Exception $e) {
         $this->__log->error(__FUNCTION__ . ": " . $e->getMessage(), ["url" => (string) $this->__url]);
         throw $e;
     }
     return $this;
 }
开发者ID:m6w6,项目名称:seekat,代码行数:36,代码来源:API.php

示例12: updateFromResponse

 /**
  * Updates the cookie jar from a Response object.
  *
  * @param Symfony\Components\BrowserKit\Response $response A Response object
  * @param string                                 $url    The base URL
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $cookie) {
         $this->set(Cookie::fromString($cookie), $uri);
     }
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:12,代码来源:CookieJar.php

示例13: updateFromResponse

 /**
  * Updates the cookie jar from a Response object.
  *
  * @param Response $response A Response object
  * @param string   $uri      The base URL
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     $cookies = array();
     foreach ($response->getHeader('Set-Cookie', false) as $cookie) {
         foreach (explode(',', $cookie) as $i => $part) {
             if (0 === $i || preg_match('/^(?P<token>\\s*[0-9A-Za-z!#\\$%\\&\'\\*\\+\\-\\.^_`\\|~]+)=/', $part)) {
                 $cookies[] = ltrim($part);
             } else {
                 $cookies[count($cookies) - 1] .= ',' . $part;
             }
         }
     }
     foreach ($cookies as $cookie) {
         $this->set(Cookie::fromString($cookie, $uri));
     }
 }
开发者ID:rouffj,项目名称:symfony,代码行数:22,代码来源:CookieJar.php

示例14: updateFromResponse

 /**
  * Updates the cookie jar from a Response object.
  *
  * @param Response $response A Response object
  * @param string   $uri      The base URL
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:10,代码来源:CookieJar.php

示例15: getResponseHeader

 /**
  * Get response header(s) after the request has been sent.
  * @param string $name Header name (optional), If name was given and and not found NULL is returned
  * @param string $default Default value in case header with $name was not found
  * @return array|string|NULL
  */
 public function getResponseHeader($name = NULL, $default = NULL)
 {
     return $this->response->getHeader($name, $default);
 }
开发者ID:novotnyj,项目名称:http-helper,代码行数:10,代码来源:Request.php


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