本文整理汇总了PHP中TYPO3\Flow\Http\Request::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getUri方法的具体用法?PHP Request::getUri怎么用?PHP Request::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Http\Request
的用法示例。
在下文中一共展示了Request::getUri方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSignatureContent
/**
* Get the content for the signature from the given request
*
* @param \TYPO3\Flow\Http\Request $httpRequest
* @return string
*/
public function getSignatureContent(\TYPO3\Flow\Http\Request $httpRequest)
{
$date = $httpRequest->getHeader('Date');
$dateValue = $date instanceof \DateTime ? $date->format(DATE_RFC2822) : '';
$signData = $httpRequest->getMethod() . chr(10) . sha1($httpRequest->getContent()) . chr(10) . $httpRequest->getHeader('Content-Type') . chr(10) . $dateValue . chr(10) . $httpRequest->getUri();
return $signData;
}
示例2: __construct
/**
*
*/
public function __construct($message, $code, \TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Http\Request $request = NULL, \Exception $previous = NULL)
{
$this->response = $response;
$this->request = $request;
if ($request !== NULL) {
$message = sprintf("[%s %s]: %s\n\nRequest data: %s", $request->getMethod(), $request->getUri(), $message . '; Response body: ' . $response->getContent(), $request->getContent());
}
parent::__construct($message, $code, $previous);
}
示例3: createRequest
/**
* Creates a PSR-7 compatible request
*
* @param \TYPO3\Flow\Http\Request $nativeRequest Flow request object
* @param array $files List of uploaded files like in $_FILES
* @param array $query List of uploaded files like in $_GET
* @param array $post List of uploaded files like in $_POST
* @param array $cookies List of uploaded files like in $_COOKIES
* @param array $server List of uploaded files like in $_SERVER
* @return \Psr\Http\Message\ServerRequestInterface PSR-7 request object
*/
protected function createRequest(\TYPO3\Flow\Http\Request $nativeRequest, array $files, array $query, array $post, array $cookies, array $server)
{
$server = ServerRequestFactory::normalizeServer($server);
$files = ServerRequestFactory::normalizeFiles($files);
$headers = $nativeRequest->getHeaders()->getAll();
$uri = (string) $nativeRequest->getUri();
$method = $nativeRequest->getMethod();
$body = new Stream('php://temp', 'wb+');
$body->write($nativeRequest->getContent());
return new ServerRequest($server, $files, $uri, $method, $body, $headers, $cookies, $query, $post);
}
示例4: startAuthentication
/**
* Starts the authentication by redirecting to the SSO endpoint
*
* The redirect includes the callback URI (the original URI from the given request)
* the client identifier and a signature of the arguments with the client private key.
*
* @param \TYPO3\Flow\Http\Request $request The current request
* @param \TYPO3\Flow\Http\Response $response The current response
* @return void
*/
public function startAuthentication(Request $request, Response $response)
{
$callbackUri = $request->getUri();
if (!isset($this->options['server'])) {
throw new Exception('Missing "server" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.', 1351690358);
}
$ssoServer = $this->ssoServerFactory->create($this->options['server']);
$ssoClient = $this->ssoClientFactory->create();
$redirectUri = $ssoServer->buildAuthenticationEndpointUri($ssoClient, $callbackUri);
$response->setStatus(303);
$response->setHeader('Location', $redirectUri);
}
示例5: sendRequest
/**
* Sends the given HTTP request
*
* @param \TYPO3\Flow\Http\Request $request
* @return \TYPO3\Flow\Http\Response The response or FALSE
* @api
* @throws \TYPO3\Flow\Http\Exception
* @throws CurlEngineException
*/
public function sendRequest(Request $request)
{
if (!extension_loaded('curl')) {
throw new \TYPO3\Flow\Http\Exception('CurlEngine requires the PHP CURL extension to be installed and loaded.', 1346319808);
}
$requestUri = $request->getUri();
$curlHandle = curl_init((string) $requestUri);
curl_setopt_array($curlHandle, $this->options);
// Send an empty Expect header in order to avoid chunked data transfer (which we can't handle yet).
// If we don't set this, cURL will set "Expect: 100-continue" for requests larger than 1024 bytes.
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array('Expect:'));
// If the content is a stream resource, use cURL's INFILE feature to stream it
$content = $request->getContent();
if (is_resource($content)) {
curl_setopt_array($curlHandle, array(CURLOPT_INFILE => $content, CURLOPT_INFILESIZE => $request->getHeader('Content-Length')));
}
switch ($request->getMethod()) {
case 'GET':
if ($request->getContent()) {
// workaround because else the request would implicitly fall into POST:
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'GET');
if (!is_resource($content)) {
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $content);
}
}
break;
case 'POST':
curl_setopt($curlHandle, CURLOPT_POST, TRUE);
if (!is_resource($content)) {
$body = $content !== '' ? $content : http_build_query($request->getArguments());
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $body);
}
break;
case 'PUT':
curl_setopt($curlHandle, CURLOPT_PUT, TRUE);
if (!is_resource($content) && $content !== '') {
$inFileHandler = fopen('php://temp', 'r+');
fwrite($inFileHandler, $request->getContent());
rewind($inFileHandler);
curl_setopt_array($curlHandle, array(CURLOPT_INFILE => $inFileHandler, CURLOPT_INFILESIZE => strlen($request->getContent())));
}
break;
default:
if (!is_resource($content)) {
$body = $content !== '' ? $content : http_build_query($request->getArguments());
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $request->getMethod());
}
$preparedHeaders = array();
foreach ($request->getHeaders()->getAll() as $fieldName => $values) {
foreach ($values as $value) {
$preparedHeaders[] = $fieldName . ': ' . $value;
}
}
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $preparedHeaders);
// curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP && CURLPROTO_HTTPS);
// CURLOPT_UPLOAD
if ($requestUri->getPort() !== NULL) {
curl_setopt($curlHandle, CURLOPT_PORT, $requestUri->getPort());
}
// CURLOPT_COOKIE
$curlResult = curl_exec($curlHandle);
if ($curlResult === FALSE) {
throw new CurlEngineException(sprintf('cURL reported error code %s with message "%s". Last requested URL was "%s" (%s).', curl_errno($curlHandle), curl_error($curlHandle), curl_getinfo($curlHandle, CURLINFO_EFFECTIVE_URL), $request->getMethod()), 1338906040);
} elseif (strlen($curlResult) === 0) {
return FALSE;
}
curl_close($curlHandle);
$response = Response::createFromRaw($curlResult);
if ($response->getStatusCode() === 100) {
$response = Response::createFromRaw($response->getContent(), $response);
}
return $response;
}
示例6: buildRouteCacheIdentifier
/**
* Generates the Matching cache identifier for the given Request
*
* @param Request $httpRequest
* @return string
*/
protected function buildRouteCacheIdentifier(Request $httpRequest)
{
return md5(sprintf('%s_%s_%s', $httpRequest->getUri()->getHost(), $httpRequest->getRelativePath(), $httpRequest->getMethod()));
}
示例7: constructorCorrectlyStripsOffIndexPhpFromRequestUri
/**
* @param string $host
* @param string $requestUri
* @param string $expectedUri
* @test
* @dataProvider constructorCorrectlyStripsOffIndexPhpFromRequestUriDataProvider
*/
public function constructorCorrectlyStripsOffIndexPhpFromRequestUri($host, $requestUri, $expectedUri)
{
$server = array('HTTP_HOST' => $host, 'REQUEST_URI' => $requestUri);
$request = new Request(array(), array(), array(), $server);
$this->assertEquals($expectedUri, (string) $request->getUri());
}
示例8: getReturnsTheRequestUri
/**
* RFC 2616 / 5.1.2
*
* @test
*/
public function getReturnsTheRequestUri()
{
$server = array('HTTP_HOST' => 'dev.blog.rob', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/foo/bar', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php');
$uri = new Uri('http://dev.blog.rob/foo/bar');
$request = new Request(array(), array(), array(), $server);
$this->assertEquals($uri, $request->getUri());
}