CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 徽标和商标
  • 商业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(Github)
    • 面包店
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Middleware
      • Session
      • TestSuite
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

类 HttpsEnforcerMiddleware

强制请求使用 HTTPS(SSL)。

命名空间: Cake\Http\Middleware

属性摘要

  • $config protected
    array<string, mixed>

    配置。

方法摘要

  • __construct() public

    构造函数

  • addHsts() protected

    在响应中添加 Strict-Transport-Security 头。

  • process() public

    检查请求是否使用 HTTPS 发出。

方法详情

__construct() ¶ public

__construct(array<string, mixed> $config = [])

构造函数

参数
array<string, mixed> $config optional

要使用的选项。

另请参阅
\Cake\Http\Middleware\HttpsEnforcerMiddleware::$config

addHsts() ¶ protected

addHsts(Psr\Http\Message\ResponseInterface $response): Psr\Http\Message\ResponseInterface

在响应中添加 Strict-Transport-Security 头。

参数
Psr\Http\Message\ResponseInterface $response

响应

返回
Psr\Http\Message\ResponseInterface

process() ¶ public

process(ServerRequestInterface $request, RequestHandlerInterface $handler): Psr\Http\Message\ResponseInterface

检查请求是否使用 HTTPS 发出。

根据配置和请求方法,重定向到具有 https 的相同 URL 或抛出异常。

参数
ServerRequestInterface $request

请求。

RequestHandlerInterface $handler

请求处理程序。

返回
Psr\Http\Message\ResponseInterface
抛出
Cake\Http\Exception\BadRequestException

属性详情

$config ¶ protected

配置。

选项

  • redirect - 如果设置为 true(默认),则将 GET 请求重定向到具有 https 的相同 URL。

  • statusCode - 重定向时要使用的状态代码,默认为 301 - 永久重定向。

  • headers - 重定向时响应头的数组。

  • disableOnDebug - 调试开启时是否应该禁用 HTTPS 检查。默认值为 true。

  • trustedProxies - 将传递给请求的可信代理的数组。默认为 null。

  • 'hsts' - 用于 HTTPS 响应配置的 Strict-Transport-Security 头。默认为 null。如果启用,则为配置选项数组

  • 'maxAge' - max-age 指令值,以秒为单位。

    • 'includeSubDomains' - 是否包含 includeSubDomains 指令。默认为 false。
    • 'preload' - 是否包含 'preload' 指令。默认为 false。
类型
array<string, mixed>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 徽标和商标
  • 社区
  • 参与
  • 问题(Github)
  • 面包店
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成