本文整理汇总了PHP中HttpResponse::create方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::create方法的具体用法?PHP HttpResponse::create怎么用?PHP HttpResponse::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRedirectResponse
public function getRedirectResponse()
{
if (!$this->isRedirect()) {
throw new RuntimeException('This response does not support redirection.');
}
$output = json_encode($this->getData());
return HttpResponse::create($output);
}
示例2: createResponse
/**
* creates instance to test
*
* @param string $response content of response
* @return HttpResponse
*/
private function createResponse(string $response) : HttpResponse
{
$file = vfsStream::newFile('response')->withContent($response)->at(vfsStream::setup());
return HttpResponse::create(new Stream(fopen($file->url(), 'rb+')));
}
示例3: exceptionHandler
/**
* API PHP Exception handler.
* This is a generic exception handler for PHP exceptions. This will catch any
* uncaught exception, end API execution and return the result to the requestor
* as an ErrorResult in the requested format.
*
* @param Exception $exception Exception
*
* @return void
* @access private
*/
public function exceptionHandler($exception)
{
$time = date("Y-m-d H:i:s (T)");
$msg = $exception->getMessage() ?: elgg_echo('Exception:UnknownType');
$code = $exception->getCode() ?: 500;
$error = "{$time}: {$msg} in file {$exception->getFile()} (line {$exception->getLine()})";
$this->log($error, "EXCEPTION");
$result = new ErrorResult($msg, $code, $exception);
if ($this->router) {
$this->router->send($result);
} else {
$output = elgg_view('graph/output', array('result' => $result));
if (elgg_get_viewtype() === 'default') {
$layout = elgg_view_layout('one_column', array('content' => $output));
$output = elgg_view_page('', $layout);
}
HttpResponse::create($output, $result->getStatusCode())->send();
}
}
示例4: delete
/**
* initializes a put request
*
* @param int $timeout optional connection timeout, defaults to 30 seconds
* @param string|\stubbles\peer\http\HttpVersion $version optional http version, defaults to HTTP/1.1
* @return \stubbles\peer\http\HttpResponse
* @since 2.0.0
*/
public function delete(int $timeout = 30, $version = HttpVersion::HTTP_1_1) : HttpResponse
{
$socket = $this->httpUri->openSocket($timeout);
$this->processHeader($socket, Http::DELETE, $version);
return HttpResponse::create($socket);
}