本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::getScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getScheme方法的具体用法?PHP RequestInterface::getScheme怎么用?PHP RequestInterface::getScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getScheme方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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];
}
示例2: add_proxy
private function add_proxy(RequestInterface $request, &$options, $value, &$params)
{
if (!is_array($value)) {
$options['http']['proxy'] = $value;
$options['http']['request_fulluri'] = true;
} else {
$scheme = $request->getScheme();
if (isset($value[$scheme])) {
$options['http']['proxy'] = $value[$scheme];
$options['http']['request_fulluri'] = true;
}
}
}
示例3: add_proxy
private function add_proxy(RequestInterface $request, RequestMediator $mediator, &$options, $value)
{
if (!is_array($value)) {
$options[CURLOPT_PROXY] = $value;
} else {
$scheme = $request->getScheme();
if (isset($value[$scheme])) {
$options[CURLOPT_PROXY] = $value[$scheme];
}
}
}
示例4: 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));
}
}
示例5: 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)));
}
}
}
}
示例6: createRedirectRequest
/**
* Create a redirect request for a specific request object
*
* Takes into account strict RFC compliant redirection (e.g. redirect POST
* with POST) vs doing what most clients do (e.g. redirect POST with GET).
*
* @param RequestInterface $request
* @param ResponseInterface $response
*
* @return RequestInterface Returns a new redirect request
* @throws CouldNotRewindStreamException If the body cannot be rewound.
*/
private function createRedirectRequest(RequestInterface $request, ResponseInterface $response)
{
$config = $request->getConfig();
// Use a GET request if this is an entity enclosing request and we are
// not forcing RFC compliance, but rather emulating what all browsers
// would do. Be sure to disable redirects on the clone.
$redirectRequest = clone $request;
$redirectRequest->getEmitter()->detach($this);
$statusCode = $response->getStatusCode();
if ($statusCode == 303 || $statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) {
$redirectRequest->setMethod('GET');
$redirectRequest->setBody(null);
}
$this->setRedirectUrl($redirectRequest, $response);
$this->rewindEntityBody($redirectRequest);
// Add the Referer header if it is told to do so and only
// add the header if we are not redirecting from https to http.
if ($config->getPath('redirect/referer') && ($redirectRequest->getScheme() == 'https' || $redirectRequest->getScheme() == $request->getScheme())) {
$url = Url::fromString($request->getUrl());
$url->setUsername(null)->setPassword(null);
$redirectRequest->setHeader('Referer', (string) $url);
}
return $redirectRequest;
}
示例7: 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()];
}