本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface::setUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::setUrl方法的具体用法?PHP RequestInterface::setUrl怎么用?PHP RequestInterface::setUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::setUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onOpen
/**
* {@inheritdoc}
* @throws \UnexpectedValueException If a controller is not \Ratchet\Http\HttpServerInterface
*/
public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
{
if (null === $request) {
throw new \UnexpectedValueException('$request can not be null');
}
$context = $this->_matcher->getContext();
$context->setMethod($request->getMethod());
$context->setHost($request->getHost());
try {
$route = $this->_matcher->match($request->getPath());
} catch (MethodNotAllowedException $nae) {
return $this->close($conn, 403);
} catch (ResourceNotFoundException $nfe) {
return $this->close($conn, 404);
}
if (is_string($route['_controller']) && class_exists($route['_controller'])) {
$route['_controller'] = new $route['_controller']();
}
if (!$route['_controller'] instanceof HttpServerInterface) {
throw new \UnexpectedValueException('All routes must implement Ratchet\\Http\\HttpServerInterface');
}
$parameters = array();
foreach ($route as $key => $value) {
if (is_string($key) && '_' !== substr($key, 0, 1)) {
$parameters[$key] = $value;
}
}
$url = Url::factory($request->getPath());
$url->setQuery($parameters);
$request->setUrl($url);
$conn->controller = $route['_controller'];
$conn->controller->onOpen($conn, $request);
}