本文整理汇总了PHP中HttpRequest::create方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpRequest::create方法的具体用法?PHP HttpRequest::create怎么用?PHP HttpRequest::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCurlException
public function testCurlException()
{
$request = HttpRequest::create()->setUrl(HttpUrl::create()->parse('http://nonexistentdomain.xyz'))->setMethod(HttpMethod::get());
try {
$response = CurlHttpClient::create()->setTimeout(3)->send($request);
$this->fail();
} catch (NetworkException $e) {
$this->assertContains('curl error', $e->getMessage());
}
}
示例2: buildRequest
/**
* @param string $url
* @return HttpRequest
**/
protected function buildRequest($url)
{
ServerVarUtils::build($_SERVER, $url);
return HttpRequest::create()->setServer($_SERVER);
}
示例3: define
<?php
/**
* $Id$
**/
define('PATH_SOURCE_DIR', 'admin' . DIRECTORY_SEPARATOR);
require '../../../config.inc.php';
try {
$request = HttpRequest::create()->setGet($_GET)->setPost($_POST)->setCookie($_COOKIE)->setServer($_SERVER)->setSession($_SESSION)->setFiles($_FILES);
$controllerName = 'main';
if (isset($_GET['area']) && is_readable(PATH_CONTROLLERS . $_GET['area'] . EXT_CLASS)) {
$controllerName = $_GET['area'];
}
$controller = new AuthorizationFilter(new $controllerName());
$modelAndView = $controller->handleRequest($request);
$view = $modelAndView->getView();
$model = $modelAndView->getModel();
$prefix = PATH_WEB_ADMIN . '?area=';
if (!$view) {
$view = $controllerName;
} elseif (is_string($view) && $view == 'error') {
$view = new RedirectView($prefix);
} elseif ($view instanceof RedirectToView) {
$view->setPrefix($prefix);
}
if (!$view instanceof View) {
$viewName = $view;
$view = PhpViewResolver::create(PATH_TEMPLATES, EXT_TPL)->resolveViewName($viewName);
}
if (!$view instanceof RedirectView) {
$model->set('selfUrl', $_SERVER['PHP_SELF'] . '?area=' . $controllerName)->set('baseUrl', $_SERVER['PHP_SELF']);
示例4: loadXRDS
protected function loadXRDS($url)
{
$response = $this->httpClient->send(HttpRequest::create()->setHeaderVar('Accept', self::HEADER_ACCEPT)->setMethod(HttpMethod::get())->setUrl(HttpUrl::create()->parse($url)));
if ($response->getStatus()->getId() != 200) {
throw new OpenIdException('can\'t fetch document');
}
$this->parseXRDS($response->getBody());
return $this;
}
示例5: buildRequest
/**
* @param string $host
* @return HttpRequest
**/
protected function buildRequest($host, $schema = 'http')
{
ServerVarUtils::build($_SERVER, $schema . '://' . $host);
return HttpRequest::create()->setServer($_SERVER);
}
示例6: checkAuthentication
/**
* check_authentication mode request
**/
private function checkAuthentication(array $parameters, $manager = null)
{
$credentials = new OpenIdCredentials(HttpUrl::create()->parse($parameters['openid.identity']), $this->httpClient);
$request = HttpRequest::create()->setMethod(HttpMethod::post())->setUrl($credentials->getServer());
if (isset($parameters['openid.invalidate_handle']) && $manager) {
$request->setPostVar('openid.invalidate_handle', $parameters['openid.invalidate_handle']);
}
foreach (explode(',', $parameters['openid.signed']) as $key) {
$key = 'openid.' . $key;
$request->setPostVar($key, $parameters[$key]);
}
$request->setPostVar('openid.mode', 'check_authentication')->setPostVar('openid.assoc_handle', $parameters['openid.assoc_handle'])->setPostVar('openid.sig', $parameters['openid.sig'])->setPostVar('openid.signed', $parameters['openid.signed']);
$response = $this->httpClient->send($request);
if ($response->getStatus()->getId() != HttpStatus::CODE_200) {
throw new OpenIdException('bad response code from server');
}
$result = $this->parseKeyValueFormat($response->getBody());
if (!isset($result['is_valid']) || $result['is_valid'] !== 'true' && $result['is_valid'] !== 'false') {
throw new OpenIdException('strange response given');
}
if ($result['is_valid'] === 'true') {
if (isset($result['invalidate_handle']) && $manager) {
$manager->purgeByHandle($result['invalidate_handle']);
}
return true;
} elseif ($result['is_valid'] === 'false') {
return false;
}
Assert::isUnreachable();
}
示例7: buildIncorrectRequest
protected function buildIncorrectRequest()
{
return HttpRequest::create();
}
示例8: spawnRequest
/**
* @param HttpMethod $method
* @return HttpRequest
*/
private function spawnRequest(HttpMethod $method, $urlPostfix = '')
{
$url = HttpUrl::create()->parse(ONPHP_CURL_TEST_URL);
$glue = $url->getQuery() ? '&' : '?';
return HttpRequest::create()->setUrl($url->parse(ONPHP_CURL_TEST_URL . $glue . $urlPostfix))->setMethod($method);
}