本文整理匯總了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);
}