本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::setMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::setMethod方法的具体用法?PHP RequestInterface::setMethod怎么用?PHP RequestInterface::setMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::setMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clientCall
protected function clientCall($path, $method = 'GET', $data = array())
{
if ($this->request instanceof RequestInterface) {
$this->request = $this->client->createRequest($method);
}
$this->request->setPath($path);
$this->request->setMethod($method);
$this->request->setQuery($data);
if (isset($this->accessToken)) {
$this->request->getQuery()->set('access_token', $this->accessToken);
}
$response = $this->client->send($this->request);
return $response->json();
}
示例2: modifyRedirectRequest
private function modifyRedirectRequest(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.
$statusCode = $response->getStatusCode();
if ($statusCode == 303 || $statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) {
$request->setMethod('GET');
$request->setBody(null);
}
$previousUrl = $request->getUrl();
$this->setRedirectUrl($request, $response);
$this->rewindEntityBody($request);
// 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') && ($request->getScheme() == 'https' || $request->getScheme() == $config['redirect_scheme'])) {
$url = Url::fromString($previousUrl);
$url->setUsername(null);
$url->setPassword(null);
$request->setHeader('Referer', (string) $url);
} else {
$request->removeHeader('Referer');
}
}
示例3: withMethod
public function withMethod($method)
{
$this->expectedRequest->setMethod($method);
return $this;
}