Cathay

Cathay

实践大于一切设想。

  • 财富值3500
  • 威望值40
  • 总积分4140

个人信息

  • 2019-10-01 已签到
    连续签到2天,获得了10个金钱
  • 这种百度一下就有答案的问题就没必要问了吧,大兄弟。
    要学会自己找办法解决问题,我看你问问题很勤。

  • 希望这段代码对你有所帮助。源码文件:
    Response.php

        /**
         * Sends the response headers to the client.
         */
        protected function sendHeaders()
        {
            if (headers_sent($file, $line)) {
                throw new HeadersAlreadySentException($file, $line);
            }
            if ($this->_headers) {
                foreach ($this->getHeaders() as $name => $values) {
                    $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
                    // set replace for first occurrence of header but false afterwards to allow multiple
                    $replace = true;
                    foreach ($values as $value) {
                        header("$name: $value", $replace);
                        $replace = false;
                    }
                }
            }
            $statusCode = $this->getStatusCode();
            header("HTTP/{$this->version} {$statusCode} {$this->statusText}");
            $this->sendCookies();
        }
    
    1. user组件指定的类(user identity class)是否继承实现 yii\filters\RateLimitInterface 接口?
    2. 控制器中行为(behaviors)中是否配置一个行为过滤器( yii\filters\RateLimiter)来执行速率限制检查,如下1. ?

      如果你继承的控制器是 yii\rest\Controller 则无需配置一个行为过滤器来执行速率限制检查,因为yii\rest\Controller中已默认添加,只要identity实现了接口,自动使用。但是如果你需要配置其他信息。如下 2.

        // 1.  
        public function behaviors()
        {
          return [
              'rateLimiter' => [
                  'class' => \yii\filters\RateLimiter::className(),
              ],
          ];
        }
        
        // 2.
        public function behaviors()
        {
            $behaviors = parent::behaviors();
            $behaviors['rateLimiter']['enableRateLimitHeaders'] = false;
            return $behaviors;
        }
    
  • 2019-09-30 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的说说
    今天是九一八,铭记历史,缅怀先烈,勿忘国耻,振兴中华!
    富强,民主,文明,和谐,自由,平等,公正,法治,爱国,敬业,诚信,友善。
  • 2019-09-12 已签到
    连续签到1天,获得了5个金钱
  • 2019-09-10 已签到
    连续签到1天,获得了5个金钱
  • 赞了说说
    祝各位老师节日快乐!从明天起签到送补签卡,连送三天,为中秋节假期把补签卡囤起来!
  • 2019-08-31 已签到
    连续签到12天,获得了20个金钱
总监 等级规则
4140/5000
资料完整度
100/100
用户活跃度
0/100

Ta的关注

4

Ta的粉丝

6

Ta的访客

24