本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getPath方法的具体用法?PHP RequestInterface::getPath怎么用?PHP RequestInterface::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getPath方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format
/**
* @inheritDoc
*/
public function format(RequestInterface $request, ResponseInterface $response = null, \Exception $error = null, array $customData = [])
{
if (in_array($request->getPath(), $this->paths)) {
$customData = array_merge(['url' => $this->mask((string) $request->getUrl()), 'resource' => $this->mask($request->getResource()), 'request' => $this->mask((string) $request), 'response' => $this->mask((string) $response), 'res_body' => $response ? $this->mask((string) $response) : 'NULL', 'req_body' => $this->mask((string) $request->getBody())], $customData);
}
return parent::format($request, $response, $error, $customData);
}
示例2: createRingRequest
/**
* Creates a Ring request from a request object.
*
* This function does not hook up the "then" and "progress" events that
* would be required for actually sending a Guzzle request through a
* RingPHP handler.
*
* @param RequestInterface $request Request to convert.
*
* @return array Converted Guzzle Ring request.
*/
public static function createRingRequest(RequestInterface $request)
{
$options = $request->getConfig()->toArray();
$url = $request->getUrl();
// No need to calculate the query string twice (in URL and query).
$qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
return ['scheme' => $request->getScheme(), 'http_method' => $request->getMethod(), 'url' => $url, 'uri' => $request->getPath(), 'headers' => $request->getHeaders(), 'body' => $request->getBody(), 'version' => $request->getProtocolVersion(), 'client' => $options, 'query_string' => $qs, 'future' => isset($options['future']) ? $options['future'] : false];
}
示例3: checkRequest
/**
* @param RequestInterface $actual
* @param RequestInterface $expected
* @throws FailedRequestExpectationException
*/
public static function checkRequest(RequestInterface $actual, RequestInterface $expected)
{
self::checkIsEqual($actual->getHost(), $expected->getHost(), 'host');
self::checkIsEqual($actual->getPath(), $expected->getPath(), 'url path');
self::checkIsEqual($actual->getMethod(), $expected->getMethod(), 'http method');
self::checkRequestQuery($actual, $expected);
self::checkContentType($actual, $expected);
self::checkRequestBody($actual, $expected);
}
示例4: getRequestAndQuery
/**
* @param RequestInterface $request
* @return array ['query' => ..., 'request' => ...]
*/
protected function getRequestAndQuery(RequestInterface $request)
{
$query = [];
foreach ($request->getQuery() as $param => $val) {
$query[$param] = $val;
}
$requestInfo = ['url' => $request->getUrl(), 'path' => $request->getPath(), 'queryString' => (string) $request->getQuery(), 'method' => $request->getMethod(), 'hostname' => $request->getHost(), 'port' => $request->getPort(), 'resource' => $request->getResource()];
return ['query' => $query, 'request' => $requestInfo];
}
示例5: __construct
public function __construct(RequestInterface $pRequest)
{
/** url parsing "formula" for resource */
list(, $subscription, $format, , $season, $week) = explode('/', $pRequest->getPath());
$file_partial = __DIR__ . '/' . implode('.', [$subscription, $format, $season, $week]);
$headers = (include $file_partial . '.header.php');
$response_code = explode(' ', $headers[0])[1];
$mocked_response = file_get_contents($file_partial . '.body.' . $format);
$stream = Stream\Stream::factory($mocked_response);
parent::__construct($response_code, $headers, $stream);
}
示例6: addCookieHeader
public function addCookieHeader(RequestInterface $request)
{
$values = array();
$scheme = $request->getScheme();
$host = $request->getHost();
$path = $request->getPath();
foreach ($this->cookies as $cookie) {
if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme == 'https')) {
$values[] = $cookie->getName() . '=' . self::getCookieValue($cookie->getValue());
}
}
if ($values) {
$request->setHeader('Cookie', implode('; ', $values));
}
}
示例7: extractCookiesArgument
/**
* @param RequestInterface $request
*/
protected function extractCookiesArgument(RequestInterface $request)
{
$listeners = $request->getEmitter()->listeners('before');
foreach ($listeners as $listener) {
if ($listener[0] instanceof Cookie) {
$values = [];
$scheme = $request->getScheme();
$host = $request->getHost();
$path = $request->getPath();
/** @var SetCookie $cookie */
foreach ($listener[0]->getCookieJar() as $cookie) {
if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme == 'https')) {
$values[] = $cookie->getName() . '=' . CookieJar::getCookieValue($cookie->getValue());
}
}
if ($values) {
$this->addOption('b', escapeshellarg(implode('; ', $values)));
}
}
}
}
示例8: getHash
/**
* Generate the hash based on the key, path and session
*
* @param RequestInterface $request
* @param Collection $config
* @return string
*/
protected function getHash(RequestInterface $request, Collection $config)
{
// Remove the /api from the path to get the correct path
$path = str_replace('/api', '', $request->getPath());
return md5($config['key'] . '#' . $path . '#' . $config['session_id']);
}
示例9: assertResponseAndRequestMatch
/**
* Asserts response match with the response schema.
*
* @param ResponseInterface $response
* @param RequestInterface $request
* @param SchemaManager $schemaManager
* @param string $message
*/
public function assertResponseAndRequestMatch(ResponseInterface $response, RequestInterface $request, SchemaManager $schemaManager, $message = '')
{
$this->assertResponseMatch($response, $schemaManager, $request->getPath(), $request->getMethod(), $message);
}
示例10: createContext
/**
* @internal Create the canonical representation of a request
* @param RequestInterface $request Request to canonicalize
* @param string $payload Hash of the request payload
* @return array Returns an array of context information
*/
private function createContext(RequestInterface $request, $payload)
{
static $signable = ['host' => true, 'date' => true, 'content-md5' => true];
// Normalize the path as required by SigV4 and ensure it's absolute
$canon = $request->getMethod() . "\n" . '/' . ltrim($request->getPath(), '/') . "\n" . $this->getCanonicalizedQuery($request) . "\n";
$canonHeaders = [];
// Always include the "host", "date", and "x-amz-" headers.
foreach ($request->getHeaders() as $key => $values) {
$key = strtolower($key);
if (isset($signable[$key]) || substr($key, 0, 6) === 'x-amz-') {
if (count($values) == 1) {
$values = $values[0];
} else {
sort($values);
$values = implode(',', $values);
}
$canonHeaders[$key] = $key . ':' . preg_replace('/\\s+/', ' ', $values);
}
}
ksort($canonHeaders);
$signedHeadersString = implode(';', array_keys($canonHeaders));
$canon .= implode("\n", $canonHeaders) . "\n\n" . $signedHeadersString . "\n" . $payload;
return ['creq' => $canon, 'headers' => $signedHeadersString];
}
示例11: collectRequest
/**
* Collect & sanitize data about a Guzzle request.
*
* @param RequestInterface $request Guzzle request.
* @return array
*/
private function collectRequest(RequestInterface $request)
{
$query = $request->getQuery();
return ['headers' => $request->getHeaders(), 'method' => $request->getMethod(), 'scheme' => $request->getScheme(), 'host' => $request->getHost(), 'path' => $request->getPath(), 'query' => (string) $query, 'queryParams' => $query->toArray(), 'body' => (string) $request->getBody()];
}
示例12: getName
/**
* @param RequestInterface $request
*
* @return string
*/
private function getName(RequestInterface $request)
{
return $request->getMethod() . ' ' . $request->getPath();
}