/*
重新结算是否选中header第一行
336196
function isCheckedHeaderRow() {
    if (this.selectRows.length !== 0 && this.selectRows.length == this.dataSourceObj.rows.length) {
        //修改全选标记为false
        $('#' + this.options.id + '_header_multi_input').addClass('is-checked');
        this.hasChecked = true;
    } else {
        $('#' + this.options.id + '_header_multi_input').removeClass('is-checked');
        this.hasChecked = false;
    }
}
227849
function refresh(body) {
    document.querySelector('body').className = 'preload';
    document.body.innerHTML = body;

    // Re-initialize the page
    init();
    autoCollapse();

    document.querySelector('body').className = '';
}
1150831
async function run() {
    let src = argv.src || argv._[0],
        dist = argv.dist || argv._[1];

    // 判断是否指定目录
    if (src) {
        console.log(src, dist);

        // 打印信息
        stdout.block('Transform File:');

        // 转码文件
        transform(path.cwd(src), dist && path.cwd(dist));
    }
}
388197
public function executeResult(): void
    {
        // 状态码
        http_response_code($this->statusCode);
        // Content-Type
        if ($this->contentType != '') {
            header('Content-Type: ' . $this->contentType);
        }
        // 额外HTTP头
        if (! empty($this->extraHeaders)) {
            foreach ($this->extraHeaders as $value) {
                header($value);
            }
        }
        // session提交
        if (Application::$app->sessionStarted) {
            Application::$app->getService('session')->commit();
        }
        // 输出
        $this->outputContent();
    }
182569
function __init()
    {
        #DEBUG
        if (defined('DEBUG') and strtolower(DEBUG) == 'on')
        {
            //记录运行时间和内存占用情况
            $this->env['runtime']['start'] = microtime(true);
            $this->env['runtime']['mem'] = memory_get_usage();
            //使用whoops美化错误页面
            if (class_exists('\\Whoops\\Run'))
            {
                $whoops = new \Whoops\Run;
                if ($this->env['sapi_name'] == 'cli')
                {
                    $whoops->pushHandler(new \Whoops\Handler\PlainTextHandler());
                }
                else
                {
                    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
                }
                $whoops->register();
            }
        }
        $this->callHook(self::HOOK_INIT);
    }
881007
private static Opt<String> newHeader(final Opt<Integer> data,
        final ByteArrayOutputStream baos) {
        Opt<String> header = new Opt.Empty<>();
        if (data.get() != ' ' && data.get() != '\t') {
            header = new Opt.Single<>(
                new Utf8String(baos.toByteArray()).asString()
            );
            baos.reset();
        }
        return header;
    }
916227
public function update(array $data)
    {
        $where = [];
        $options = $this->parseExpress();
        $data    = array_merge($options['data'], $data);
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }
        $pk = $this->getPk();
        if (empty($options['where'])) {
            // 如果存在主键数据 则自动作为更新条件
            if (is_string($pk) && isset($data[$pk])) {
                $where[$pk] = $data[$pk];
                $key        = 'mongo:' . $options['table'] . '|' . $data[$pk];
                unset($data[$pk]);
            } elseif (is_array($pk)) {
                // 增加复合主键支持
                foreach ($pk as $field) {
                    if (isset($data[$field])) {
                        $where[$field] = $data[$field];
                    } else {
                        // 如果缺少复合主键数据则不执行
                        throw new Exception('miss complex primary data');
                    }
                    unset($data[$field]);
                }
            }
            if (!isset($where)) {
                // 如果没有任何更新条件则不执行
                throw new Exception('miss update condition');
            } else {
                $options['where']['$and'] = $where;
            }
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['$and'][$pk])) {
            $key = $this->getCacheKey($options['where']['$and'][$pk], $options);
        }

        // 生成bulkWrite对象
        $bulk         = $this->builder->update($data, $options);
        $writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : null;
        $writeResult  = $this->execute($options['table'], $bulk, $writeConcern);

        $result = $writeResult->getModifiedCount();
        if ($result) {
            if (isset($where[$pk])) {
                $data[$pk] = $where[$pk];
            } elseif (is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $data[$pk]     = $val;
            }
            $options['data'] = $data;
            $this->trigger('after_update', $options);
        }
        return $result;
    }
1121956
public function start() {
        #设置DEBUG引导程序
        (new This7Debug())->bootstrap();
        #设置配置文件
        This7Config::defineConst();
        #获取驱动列表
        $this->drives = $this->getDeviceList(VENDOR_DIR . DS . 'this7');
        #自动加载类
        spl_autoload_register(array($this, 'autoload'));
        #设置静态化
        staticize::setApplication($this);
        #绑定核心驱动
        $this->bindDrives();
        #启动路由
        routes::start();
    }
233578
function(socket, expectedCommand, expectedBodyLength, callback, headerOnly) {
        var oriCallback = callback
        // 收包完毕则关闭掉连接
        callback = function() {
            cleanup()
            if (is.function(oriCallback)) {
                oriCallback.apply(null, arguments)
            }
        }
        var headerBufferLen = protocol.HEADER_BYTE_LENGTH
        var headerBuffer = new Buffer(headerBufferLen)
        // 已填充的length
        var headerBufferFilled = 0
        // 解析后的header信息
        // {status: , bodyLength: }
        var header
        var bodyBuffer
        // 下1次要copy到bodyBuffer中的起始位置
        var bodyBufferStart = 0

        socket.on('data', listener)

        function listener(data) {
            // --------------- 收到服务器发来消息
            // -------- 解析header
            if (!header) {
                // header parsed
                if (headerBufferFilled + data.length >= headerBufferLen) {
                    var len = headerBufferFilled + data.length
                    // 只copy剩下的header部分
                    data.copy(headerBuffer, headerBufferFilled, 0, headerBufferLen - headerBufferFilled)
                    try {
                        header = _parseHeader(headerBuffer, expectedCommand, expectedBodyLength)
                        logger.debug('receive server packet header: %j', header)
                        // 无body时直接返回
                        if (header.bodyLength === 0) {
                            callback(null, header)
                            return
                        }

                        if (headerOnly) {
                            oriCallback(null, header)
                            if (len > headerBufferLen) {
                                oriCallback(null, data.slice(headerBufferLen - headerBufferFilled))
                            }
                            return
                        }

                        bodyBuffer = new Buffer(header.bodyLength)

                        // 还有body的数据则填充到body buffer中
                        if (len > headerBufferLen) {
                            data.copy(bodyBuffer, 0, headerBufferLen - headerBufferFilled)
                            bodyBufferStart = len - headerBufferLen
                            // 读取完毕
                            if (bodyBufferStart >= header.bodyLength) {
                                callback(null, bodyBuffer)
                            }
                        }

                    } catch (err) {
                        callback(err)
                    }

                } else {
                    data.copy(headerBuffer, headerBufferFilled)
                    headerBufferFilled += data.length
                }

            } else {
                // 交由外部处理
                if (headerOnly) {
                    oriCallback(null, data)
                    return
                }
                // ---------- 解析body
                data.copy(bodyBuffer, bodyBufferStart)
                bodyBufferStart += data.length
                // 读取完毕
                if (bodyBufferStart >= header.bodyLength) {
                    callback(null, bodyBuffer)
                }
            }
        }

        function cleanup() {
            socket.removeListener('data', listener)
            // 关闭连接
            protocol.closeSocket(socket)
        }
    }
1213288
function(name, value) {
    var header = { raw: value };

    name = Utils.headerize(name);

    if(this.headers[name]) {
      this.headers[name].push(header);
    } else {
      this.headers[name] = [header];
    }
  }
598849
private void processLastCell(LastCellOfRowDummyRecord lastCell) {
		// 每行结束时， 调用handle() 方法
		this.rowHandler.handle(curSheetIndex, lastCell.getRow(), this.rowCellList);
		// 清空行Cache
		this.rowCellList.clear();
	}
411968
public function flush()
  {
    // God, PHP really has some esoteric ways of doing simple things.
    $host = $this->host_.($this->port_ != 80 ? ':'.$this->port_ : '');

    $headers = array();
    $defaultHeaders = array('Host' => $host,
                            'Accept' => 'application/x-thrift',
                            'User-Agent' => 'PHP/THttpClient',
                            'Content-Type' => 'application/x-thrift',
                            'Content-Length' => TStringFuncFactory::create()->strlen($this->buf_));
    foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) {
        $headers[] = "$key: $value";
    }

    $options = array('method' => 'POST',
                     'header' => implode("\r\n", $headers),
                     'max_redirects' => 1,
                     'content' => $this->buf_);
    if ($this->timeout_ > 0) {
      $options['timeout'] = $this->timeout_;
    }
    $this->buf_ = '';

    $contextid = stream_context_create(array('http' => $options));
    $this->handle_ = @fopen($this->scheme_.'://'.$host.$this->uri_, 'r', false, $contextid);

    // Connect failed?
    if ($this->handle_ === FALSE) {
      $this->handle_ = null;
      $error = 'THttpClient: Could not connect to '.$host.$this->uri_;
      throw new TTransportException($error, TTransportException::NOT_OPEN);
    }
  }
655831
function setResCookies(ctx, headers) {
    if (!headers || !validateCookies(headers['set-cookie'])) {
      return
    }

    let cookies = headers['set-cookie'];
    let _headers = ctx.res._headers || {};
    ctx.res._headerNames = ctx.res._headerNames || {}
    // 参考：https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
    // 在Nodejs 8.x的版本里res._headers被改成了getter/setter 通过 headers['set-cookies'] = 'test' 不触发setter，从而导致设置cookie报错
    ctx.res._headers = Object.assign({}, _headers, {
      'set-cookie': (_headers['set-cookie'] || []).concat(cookies)
    })
    ctx.res._headerNames['set-cookie'] = 'Set-Cookie';
  }
1238930
function() {
	  var level       = 0;
	  var levels      = [0,0,0,0,0,0,0];
	  var hLevelText  = '';
	  var prependText = '';
	  var prevLevel   = 0;
	  var n           = 0;
	  self.children('*:header:visible').each(function(index, heading) {
		log('Processing heading %o', heading);
		level = parseInt(heading.tagName.substring(1));
		if (config.min_level <= level && level <= config.max_level) {
		  n++;
		  levels[level]++;
		  for (var l = 1; l <= level; l++) {
			hLevelText += levels[l] > 0 ? levels[l] + config.number_separator : '';
		  }
		  levels[level + 1] = 0;
		  hLevelText = hLevelText.substring(0, hLevelText.length - 1);
		  prependText = hLevelText;
		  if (config.generate_toc || config.add_anchors) {
			if (config.generate_toc) {
			  var link = '<a href="#h' + hLevelText + '">' +jQuery('<span/>').text(jQuery(this).text()).html() + '</a>';
			  var elem = "\n"+'<li>' + hLevelText + (config.number_suffix ? config.number_suffix : '') + ' ' + link;
			  if (level < prevLevel) {
				log(hLevelText + ', unnesting because:' + level + '<' + prevLevel);
				var unnest = '';
				while (level < prevLevel) {
				  unnest += '</ul>';
				  prevLevel--;
				}
				toc += unnest + elem + '</li>';
			  } else if (level > prevLevel) {
				log(hLevelText + ', nesting because:' + level + '>' + prevLevel);
				toc += '<ul>' + elem;
			  } else {
				log(hLevelText + ', same level (' + level + ')');
				toc += elem;
			  }
			}
			prependText = '<span id="h' + hLevelText + '"></span>' + hLevelText;
		  }
		  if (config.number_suffix) {
			prependText += config.number_suffix;
		  }
		  jQuery(this).prepend(prependText + ' ');
		  prependText = hLevelText = '';
		  prevLevel = level;
		}
	  });

	  if (config.generate_toc) {
		if (config.toc_title) {
		  toc = '<h4>' + config.toc_title + '</h4>' + toc;
		}
		if (n == 0) {
		  toc += config.toc_none ? '<p>' + config.toc_none + '</p>' : '';
		}
		jQuery(config.toc_elem ? config.toc_elem : 'body').append(toc);
	  }

	  processed = true;
	}
425539
function (header) {
    this.httpHeader = parseHTTPHeader(header);

    if (this.httpHeader[ 'content-length' ]) this.size = this.httpHeader[ 'content-length' ];

    if (this.httpHeader[ 'content-type' ]) this.mime = this.httpHeader[ 'content-type' ];

    if (this.httpHeader[ 'last-modified' ]) this.lastModified = new Date(this.httpHeader[ 'last-modified' ]);
  }
92679
protected function start()
    {
        $pid = $this->getMasterPid();

        if ($this->isRunning($pid)) {
            $this->output->writeln('<error>swoole http server process is already running.</error>');
            return;
        }

        $this->output->writeln('Starting swoole http server...');

        /** @var Swoole $swoole */
        $swoole = $this->app->make(Swoole::class);

        if ($this->config['auto_reload']) {
            //热更新
            /** @var \Swoole\Server $server */
            $server = $this->app->make(\think\swoole\facade\Server::class);

            $server->addProcess($this->getHotReloadProcess($server, (int) $this->config['auto_reload']));
        }

        $host = $this->config['server']['host'];
        $port = $this->config['server']['port'];

        $this->output->writeln("Swoole http server started: <http://{$host}:{$port}>");
        $this->output->writeln('You can exit with <info>`CTRL-C`</info>');

        $swoole->run();
    }
422158
function finish(requester) {
        var orgHeaders = normal(requester.res.headers);
        // 恢复当前的请求上下文

        var context = requester.ctx;
        if (app.revertContext(context)) {
            // 透传响应头信息
            var res = context.res;
            headers.forEach(function (name) {
                if (orgHeaders[name]) {
                    // 直接覆盖
                    res.set(name, orgHeaders[name]);
                }
            });
        }
        // Dispose
        requester.ctx = context = null;
    }