本文整理汇总了PHP中Illuminate\Http\Request::secure方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::secure方法的具体用法?PHP Request::secure怎么用?PHP Request::secure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::secure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildCsp
/**
* Add content security policy headers to response.
*
* @return void
*
* @throws \Exception
*/
protected function buildCsp()
{
if ($this->response instanceof BinaryFileResponse) {
return;
}
$csp = CSPBuilder::fromFile(config_path('csp.json'));
$csp->addDirective('upgrade-insecure-requests', $this->request->secure());
$this->response->withHeaders($csp->getHeaderArray(false));
}
示例2: matches
/**
* Validate a given rule against a route and request.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function matches(Route $route, Request $request)
{
if ($route->httpOnly()) {
return !$request->secure();
} elseif ($route->secure()) {
return $request->secure();
}
return true;
}
示例3: handle
/**
* Redirects any non-secure requests to their secure counterparts.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return redirects to the secure counterpart of the requested uri.
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && app()->environment('production')) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && env('APP_ENV') === 'prod') {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure()) {
abort(404);
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && !str_contains($request->getRequestUri(), '/podcasts/rss')) {
return redirect()->secure($request->getRequestUri(), 301);
}
return $next($request);
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure()) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例8: root
/**
* Get route root.
*
* @return string
*/
public function root()
{
$http = $this->request->secure() ? 'https' : 'http';
$domain = trim($this->domain(true), '/');
$prefix = $this->prefix(true);
return trim("{$http}://{$domain}/{$prefix}", '/');
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure()) {
return Redirect::secure($request->path());
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure $next
*
* @return \Illuminate\Http\RedirectResponse
*/
public function handle($request, Closure $next)
{
if (env('APP_HTTPS') && !env('APP_DEBUG') && !$request->secure()) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->secure()) {
//return redirect("https://{$_SERVER['HTTP_HOST']}" . $request->getRequestUri());
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$request->setTrustedProxies([$request->getClientIp()]);
if (!$request->secure()) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && env('APP_ENV') === 'production') {
$request->setTrustedProxies([$request->getClientIp()]);
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
示例14: forceSSL
/**
* Force to use https:// requests
*
* @return null|RedirectResponse Redirects to the https:// protocol if the current request is insecure
*/
public function forceSSL()
{
if (!$this->request->secure()) {
return $this->redirect->secure($this->request->getRequestUri());
}
return null;
// The request is already secure
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// if not local environment AND the request isn't safe
if (!app()->isLocal() && !$request->secure()) {
// redirect to the mathching secure url
return redirect()->secure($request->path());
}
return $next($request);
}