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


PHP ServerRequestInterface::getHeaderLine方法代码示例

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


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

示例1: dispatch

 /**
  * Run Controller
  *
  * @param ServerRequestInterface $request  PSR7 Request object
  * @param ResponseInterface      $response PSR7 Response object
  * @param array                  $args     Request arguments
  * @return ResponseInterface
  */
 public function dispatch(Request $request, Response $response, $args)
 {
     $netid = $request->getHeaderLine('AUTH_PRINCIPAL');
     $eppa = $request->getHeaderLine('AUTH_ATTR_EDUPERSONPRIMARYAFFILIATION');
     $albumID = $args['album_id'] ?? $request->getQueryParams()['album'] ?? 1;
     $view_attr = ['page_title' => 'SlimSkeleton | Example', 'username' => $netid, 'eppa' => $eppa, 'data' => $this->service->getPhotos($albumID)];
     return $this->view->render($response, 'example.html', $view_attr);
 }
开发者ID:usf-it,项目名称:slim-skeleton,代码行数:16,代码来源:ExampleAction.php

示例2: it_can_parse_a_HttpRequest

 public function it_can_parse_a_HttpRequest(ServerRequestInterface $httpRequest)
 {
     $token = Uuid::uuid4()->toString();
     $passCode = bin2hex(random_bytes(20));
     $httpRequest->getHeaderLine('Accept')->shouldBeCalled();
     $httpRequest->getHeaderLine('Authentication-Token')->willReturn($token);
     $httpRequest->getHeaderLine('Authentication-Pass-Code')->willReturn($passCode);
     $request = $this->parseHttpRequest($httpRequest, []);
     $request->shouldHaveType(RequestInterface::class);
     $request->getRequestName()->shouldReturn(RefreshTokenHandler::MESSAGE);
     $request['token']->shouldBe($token);
     $request['pass_code']->shouldBe($passCode);
 }
开发者ID:jschreuder,项目名称:SpotCms,代码行数:13,代码来源:RefreshTokenHandlerSpec.php

示例3: isExcluded

 /**
  * {@inheritdoc}
  *
  * @throws \RuntimeException
  */
 public function isExcluded(ServerRequestInterface $request)
 {
     if (!count($this->headers)) {
         throw new \RuntimeException('No headers defined in header excluder');
     }
     foreach ($this->headers as $header => $value) {
         if ($value === null && $request->hasHeader($header)) {
             return true;
         } elseif ($value !== null && (trim($value) === $request->getHeaderLine($header) || @preg_match(trim($value), $request->getHeaderLine($header)))) {
             return true;
         }
     }
     return false;
 }
开发者ID:juliangut,项目名称:janitor,代码行数:19,代码来源:Header.php

示例4: fromPsrRequest

 /**
  * attempt to build up a request from a PSR-7 compatible request
  *
  * @param ServerRequestInterface $request
  * @return Request
  */
 public static function fromPsrRequest(ServerRequestInterface $request)
 {
     $url = (string) $request->getUri();
     $httpMethod = $request->getMethod();
     // Let's find the parameters relevant to this request
     $parameters = (array) $request->getParsedBody() + $request->getQueryParams();
     // We have a Authorization-header with OAuth data. Parse the header
     // and add those overriding any duplicates from GET or POST
     if (substr($request->getHeaderLine('Authorization'), 0, 6) == 'OAuth ') {
         $header_parameters = Util::splitHeader($request->getHeaderLine('Authorization'));
         $parameters = array_merge($parameters, $header_parameters);
     }
     return new Request($httpMethod, $url, $parameters);
 }
开发者ID:AscendLearning,项目名称:lti,代码行数:20,代码来源:Request.php

示例5: __invoke

 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     if (!($partSize = $req->getHeaderLine('x-amz-part-size'))) {
         return $res->withStatus(400)->write('Part size missing.');
     }
     if (!($desc = $req->getHeaderLine('x-amz-archive-description'))) {
         $desc = '';
     }
     $m = $vault->createMultipart($partSize, $desc);
     return $res->withStatus(201)->withHeader('x-amz-multipart-upload-id', $m->getId());
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:15,代码来源:InitiateMultipartUploadAction.php

示例6: __invoke

 /**
  * Invoking the middleware
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  * @return ResponseInterface $response
  * @throws InternalServerError
  * @throws UnsupportedMediaType
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     // Make sure we have deserializers
     if (!isset($this->container['contentTypes'])) {
         throw new InternalServerError('No serializers seems to be configured');
     }
     // Make sure we have a content type header to work with
     if ($request->hasHeader('Content-Type')) {
         // Get the content of the header
         $header = $request->getHeaderLine('Content-Type');
         // Make sure the header value isn't empty
         if (!empty($header)) {
             // Get priorities
             $supported = $this->container['contentTypes'];
             // Remove included parts that aren't part of the RFC
             $header = preg_replace('/(;[a-z]*=[a-z0-9\\-]*)/i', '', $header);
             // Replace the original header value
             $request = $request->withHeader('Content-Type', $header);
             // Check if the content type is supported
             if (!in_array($header, $supported)) {
                 // The content type isn't supported
                 throw new UnsupportedMediaType('Can not handle the supplied content type. Supported types are ' . implode(', ', $supported));
             }
         }
     }
     // Call next middleware
     return $next($request, $response, $next);
 }
开发者ID:phapi,项目名称:middleware-postbox,代码行数:38,代码来源:PostBox.php

示例7: logIn

 /**
  * @param Request $request
  * @return Request
  */
 protected function logIn(Request $request)
 {
     $header = $request->getHeaderLine('authorization');
     $parts = explode(';', $header);
     $actor = new Guest();
     if (isset($parts[0]) && starts_with($parts[0], $this->prefix)) {
         $token = substr($parts[0], strlen($this->prefix));
         if (($accessToken = AccessToken::find($token)) && $accessToken->isValid()) {
             $actor = $accessToken->user;
             $actor->updateLastSeen()->save();
         } elseif (isset($parts[1]) && ($apiKey = ApiKey::valid($token))) {
             $userParts = explode('=', trim($parts[1]));
             if (isset($userParts[0]) && $userParts[0] === 'userId') {
                 $actor = User::find($userParts[1]);
             }
         }
     }
     if ($actor->exists) {
         $locale = $actor->getPreference('locale');
     } else {
         $locale = array_get($request->getCookieParams(), 'locale');
     }
     if ($locale && $this->locales->hasLocale($locale)) {
         $this->locales->setLocale($locale);
     }
     return $request->withAttribute('actor', $actor ?: new Guest());
 }
开发者ID:ygbhf,项目名称:flarum-full,代码行数:31,代码来源:AuthenticateWithHeader.php

示例8: __invoke

 /**
  * {@inheritdoc}
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, \Closure $next)
 {
     if ($request->getHeaderLine('Content-Type') == 'application/json') {
         $request = $request->withParsedBody(json_decode($request->getBody()->__toString(), true));
     }
     return $next($request);
 }
开发者ID:jwdeitch,项目名称:components,代码行数:10,代码来源:JsonParser.php

示例9: __invoke

 /**
  * {@inheritdoc}
  */
 public function __invoke(Request $request, Response $response, callable $out = null)
 {
     if (str_contains($request->getHeaderLine('content-type'), 'json')) {
         $input = json_decode($request->getBody(), true);
         $request = $request->withParsedBody($input ?: []);
     }
     return $out ? $out($request, $response) : $response;
 }
开发者ID:asifalimd,项目名称:core,代码行数:11,代码来源:ParseJsonBody.php

示例10: modify

 public function modify(ServerRequestInterface $request) : ServerRequestInterface
 {
     if (false === strpos($request->getHeaderLine('Content-Type'), 'application/json')) {
         return $request;
     }
     // TODO: Implement broken json handling
     return $request->withParsedBody(json_decode($request->getBody()->getContents(), $this->asAssociativeArray));
 }
开发者ID:ThrusterIO,项目名称:http-modifiers,代码行数:8,代码来源:ParseJsonRequestBodyModifier.php

示例11: __invoke

 /**
  * {@inheritdoc}
  */
 public function __invoke(Request $request, Response $response, callable $out = null)
 {
     if ($request->getMethod() === 'POST' && $request->hasHeader(self::HEADER_NAME)) {
         $fakeMethod = $request->getHeaderLine(self::HEADER_NAME);
         $request = $request->withMethod(strtoupper($fakeMethod));
     }
     return $out ? $out($request, $response) : $response;
 }
开发者ID:clops,项目名称:core,代码行数:11,代码来源:FakeHttpMethods.php

示例12: __invoke

 /**
  * Execute the middleware.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @param callable               $next
  *
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     $authorization = self::parseAuthorizationHeader($request->getHeaderLine('Authorization'));
     if ($authorization && $this->checkUserPassword($authorization['username'], $authorization['password'])) {
         return $next(Middleware::setAttribute($request, self::KEY, $authorization['username']), $response);
     }
     return $response->withStatus(401)->withHeader('WWW-Authenticate', 'Basic realm="' . $this->realm . '"');
 }
开发者ID:wolfy-j,项目名称:psr7-middlewares,代码行数:17,代码来源:BasicAuthentication.php

示例13: isNotModified

 /**
  * Check the not modified header.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request The request to check.
  * @param \Cake\Filesystem\File $file The file object to compare.
  * @return bool
  */
 protected function isNotModified($request, $file)
 {
     $modifiedSince = $request->getHeaderLine('If-Modified-Since');
     if (!$modifiedSince) {
         return false;
     }
     return strtotime($modifiedSince) === $file->lastChange();
 }
开发者ID:markstory,项目名称:cakephp-spekkoek,代码行数:15,代码来源:AssetMiddleware.php

示例14: getAuth

 /**
  * Retrieve request authentication information.
  *
  * @param ServerRequestInterface $request
  *
  * @return array
  */
 protected function getAuth(ServerRequestInterface $request)
 {
     $authHeader = $request->getHeaderLine('Authorization');
     if (preg_match('/^Basic /', $authHeader)) {
         $auth = explode(':', base64_decode(substr($authHeader, 6)), 2);
         return ['username' => $auth[0], 'password' => isset($auth[1]) ? $auth[1] : null];
     }
 }
开发者ID:juliangut,项目名称:janitor,代码行数:15,代码来源:BasicAuth.php

示例15: isValid

 /**
  * Validate authorization token
  * @param Request $request
  * @return boolean
  */
 private function isValid(Request $request)
 {
     $token = $request->getHeaderLine('authorization');
     if ($token == 'pasando') {
         return true;
     }
     return false;
 }
开发者ID:AV4TAr,项目名称:middleware-zend-expressive,代码行数:13,代码来源:Auth.php


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