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


PHP RequestInterface::getRequestTarget方法代码示例

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


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

示例1: handleRequest

 /**
  * {@inheritdoc}
  */
 public function handleRequest(RequestInterface $request, callable $next, callable $first)
 {
     // Check in storage
     if (array_key_exists($request->getRequestTarget(), $this->redirectStorage)) {
         $uri = $this->redirectStorage[$request->getRequestTarget()]['uri'];
         $statusCode = $this->redirectStorage[$request->getRequestTarget()]['status'];
         $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode);
         return $first($redirectRequest);
     }
     return $next($request)->then(function (ResponseInterface $response) use($request, $first) {
         $statusCode = $response->getStatusCode();
         if (!array_key_exists($statusCode, $this->redirectCodes)) {
             return $response;
         }
         $uri = $this->createUri($response, $request);
         $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode);
         $chainIdentifier = spl_object_hash((object) $first);
         if (!array_key_exists($chainIdentifier, $this->circularDetection)) {
             $this->circularDetection[$chainIdentifier] = [];
         }
         $this->circularDetection[$chainIdentifier][] = $request->getRequestTarget();
         if (in_array($redirectRequest->getRequestTarget(), $this->circularDetection[$chainIdentifier])) {
             throw new CircularRedirectionException('Circular redirection detected', $request, $response);
         }
         if ($this->redirectCodes[$statusCode]['permanent']) {
             $this->redirectStorage[$request->getRequestTarget()] = ['uri' => $uri, 'status' => $statusCode];
         }
         // Call redirect request in synchrone
         $redirectPromise = $first($redirectRequest);
         return $redirectPromise->wait();
     });
 }
开发者ID:php-http,项目名称:plugins,代码行数:35,代码来源:RedirectPlugin.php

示例2: request

 /**
  * Send a request to the server and return a Response object with the response.
  *
  * @param   RequestInterface $request The request object to send.
  *
  * @return  ResponseInterface
  *
  * @since   2.1
  */
 public function request(RequestInterface $request)
 {
     $uri = $request->getUri()->withPath(null)->withQuery(null)->withFragment(null);
     $uri = $uri . $request->getRequestTarget();
     $request = $request->withRequestTarget($uri);
     return $this->doRequest($request);
 }
开发者ID:kaiwa,项目名称:http,代码行数:16,代码来源:AbstractTransport.php

示例3: formatRequest

 /**
  * {@inheritdoc}
  */
 public function formatRequest(RequestInterface $request)
 {
     $message = sprintf("%s %s HTTP/%s\n", $request->getMethod(), $request->getRequestTarget(), $request->getProtocolVersion());
     foreach ($request->getHeaders() as $name => $values) {
         $message .= $name . ': ' . implode(', ', $values) . "\n";
     }
     return $this->addBody($request, $message);
 }
开发者ID:php-http,项目名称:message,代码行数:11,代码来源:FullHttpMessageFormatter.php

示例4: transformRequestHeadersToString

 /**
  * Produce the header of request as a string based on a PSR Request
  *
  * @param RequestInterface $request
  *
  * @return string
  */
 protected function transformRequestHeadersToString(RequestInterface $request)
 {
     $message = vsprintf('%s %s HTTP/%s', [strtoupper($request->getMethod()), $request->getRequestTarget(), $request->getProtocolVersion()]) . "\r\n";
     foreach ($request->getHeaders() as $name => $values) {
         $message .= $name . ': ' . implode(', ', $values) . "\r\n";
     }
     $message .= "\r\n";
     return $message;
 }
开发者ID:printu,项目名称:socket-client,代码行数:16,代码来源:RequestWriter.php

示例5:

 function it_creates_an_http_exception(RequestInterface $request, ResponseInterface $response)
 {
     $request->getRequestTarget()->willReturn('/uri');
     $request->getMethod()->willReturn('GET');
     $response->getStatusCode()->willReturn(100);
     $response->getReasonPhrase()->willReturn('Continue');
     $e = $this->create($request, $response);
     $e->shouldHaveType('Http\\Client\\Exception\\HttpException');
     $e->getMessage()->shouldReturn('[url] /uri [http method] GET [status code] 100 [reason phrase] Continue');
 }
开发者ID:joelwurtz,项目名称:php-http-master,代码行数:10,代码来源:HttpExceptionSpec.php

示例6: getFileName

 protected function getFileName(RequestInterface $request)
 {
     $result = trim($request->getMethod() . ' ' . $request->getRequestTarget()) . ' HTTP/' . $request->getProtocolVersion();
     foreach ($request->getHeaders() as $name => $values) {
         if (array_key_exists(strtoupper($name), $this->ignored_headers)) {
             continue;
         }
         $result .= "\r\n{$name}: " . implode(', ', $values);
     }
     $request = $result . "\r\n\r\n" . $request->getBody();
     return md5((string) $request) . ".txt";
 }
开发者ID:Lidbetter,项目名称:GuzzleRecorder,代码行数:12,代码来源:GuzzleRecorder.php

示例7: toString

 /**
  * Serialize a request message to a string.
  *
  * @param RequestInterface $request
  * @return string
  */
 public static function toString(RequestInterface $request)
 {
     $headers = self::serializeHeaders($request->getHeaders());
     $body = (string) $request->getBody();
     $format = '%s %s HTTP/%s%s%s';
     if (!empty($headers)) {
         $headers = "\r\n" . $headers;
     }
     if (!empty($body)) {
         $headers .= "\r\n\r\n";
     }
     return sprintf($format, $request->getMethod(), $request->getRequestTarget(), $request->getProtocolVersion(), $headers, $body);
 }
开发者ID:deepfreeze,项目名称:zend-diactoros,代码行数:19,代码来源:Serializer.php

示例8: create

 public static function create(RequestInterface $request, ResponseInterface $response, HalResource $resource, $previous = null, $message = null)
 {
     if (!$message) {
         $code = $response->getStatusCode();
         if ($code >= 400 && $code < 500) {
             $message = 'Client error';
         } elseif ($code >= 500 && $code < 600) {
             $message = 'Server error';
         } else {
             $message = 'Unsuccessful response';
         }
     }
     $message = sprintf('%s [url] %s [http method] %s [status code] %s [reason phrase] %s.', $message, $request->getRequestTarget(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase());
     return new self($message, $request, $response, $resource, $previous);
 }
开发者ID:jsor,项目名称:hal-client,代码行数:15,代码来源:BadResponseException.php

示例9: toString

 /**
  * Serialize a request message to a string.
  *
  * @param RequestInterface $request
  * @return string
  */
 public static function toString(RequestInterface $request)
 {
     $httpMethod = $request->getMethod();
     if (empty($httpMethod)) {
         throw new UnexpectedValueException('Object can not be serialized because HTTP method is empty');
     }
     $headers = self::serializeHeaders($request->getHeaders());
     $body = (string) $request->getBody();
     $format = '%s %s HTTP/%s%s%s';
     if (!empty($headers)) {
         $headers = "\r\n" . $headers;
     }
     if (!empty($body)) {
         $headers .= "\r\n\r\n";
     }
     return sprintf($format, $httpMethod, $request->getRequestTarget(), $request->getProtocolVersion(), $headers, $body);
 }
开发者ID:zendframework,项目名称:zend-diactoros,代码行数:23,代码来源:Serializer.php

示例10: create

 /**
  * {@inheritdoc}
  */
 public static function create(HttpRequestInterface $request, HttpResponseInterface $response = null, Exception $previous = null, array $handlerContext = null)
 {
     if ($request instanceof RequestInterface && $response instanceof ResponseInterface) {
         static $clientErrorCodes = [-32600, -32601, -32602, -32700];
         $errorCode = $response->getRpcErrorCode();
         if (in_array($errorCode, $clientErrorCodes)) {
             $label = 'Client RPC error response';
             $className = __NAMESPACE__ . '\\ClientException';
         } else {
             $label = 'Server RPC error response';
             $className = __NAMESPACE__ . '\\ServerException';
         }
         $message = $label . ' [uri] ' . $request->getRequestTarget() . ' [method] ' . $request->getRpcMethod() . ' [error code] ' . $errorCode . ' [error message] ' . $response->getRpcErrorMessage();
         return new $className($message, $request, $response, $previous);
     }
     return parent::create($request, $response, $previous);
 }
开发者ID:yashb,项目名称:generator,代码行数:20,代码来源:RequestException.php

示例11: normalizeRequestToString

 /**
  * Normalize a request to string.
  *
  * @param RequestInterface $request
  *
  * @return string
  */
 public function normalizeRequestToString(RequestInterface $request)
 {
     return sprintf('%s %s %s', $request->getMethod(), $request->getRequestTarget(), $request->getProtocolVersion());
 }
开发者ID:Nyholm,项目名称:plugins,代码行数:11,代码来源:Normalizer.php

示例12: runMatches

 protected function runMatches(RequestInterface $request)
 {
     return $request->getRequestTarget() == $this->expected;
 }
开发者ID:oscarotero,项目名称:psr7-unitesting,代码行数:4,代码来源:RequestTarget.php

示例13: getRequestTarget

 /**
  * @return string
  */
 public function getRequestTarget()
 {
     return $this->request->getRequestTarget();
 }
开发者ID:bweston92,项目名称:expressive-async,代码行数:7,代码来源:ServerRequest.php

示例14: create

 /**
  * Factory method to create a new exception with a normalized error message
  *
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  * @param \Exception|null   $previous
  *
  * @return HttpException
  */
 public static function create(RequestInterface $request, ResponseInterface $response, \Exception $previous = null)
 {
     $message = sprintf('[url] %s [http method] %s [status code] %s [reason phrase] %s', $request->getRequestTarget(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase());
     return new self($message, $request, $response, $previous);
 }
开发者ID:xabbuh,项目名称:httplug,代码行数:14,代码来源:HttpException.php

示例15: getName

 /**
  * GetName
  *
  * @param Request $request request
  *
  * @return string
  *
  * @access protected
  */
 protected function getName(Request $request)
 {
     if (!($path = $request->getAttribute('jnjxp/viewd:script'))) {
         $path = parse_url($request->getRequestTarget(), PHP_URL_PATH);
         $path = trim($path, '/');
     }
     $name = $this->prefix . DIRECTORY_SEPARATOR . ($path ? $path : 'index');
     return $name;
 }
开发者ID:jnjxp,项目名称:viewd,代码行数:18,代码来源:Viewd.php


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