fix(http): Ihttp 响应头解析前初始化 headers 数组,消除未定义索引告警

This commit is contained in:
kuaifan 2026-07-15 10:45:01 +00:00
parent 13ba1d3bd7
commit e4fbf9693a

View File

@ -196,13 +196,14 @@ class Ihttp
$rlt['status'] = $matches[3];
$rlt['responseline'] = $split2[0];
$header = explode("\r\n", $split2[1]);
$rlt['headers'] = [];
$isgzip = false;
$ischunk = false;
foreach ($header as $v) {
$row = explode(':', $v);
$key = trim($row[0]);
$value = trim(substr($v, strlen($row[0]) + 1));
if (is_array($rlt['headers'][$key])) {
if (isset($rlt['headers'][$key]) && is_array($rlt['headers'][$key])) {
$rlt['headers'][$key][] = $value;
} elseif (!empty($rlt['headers'][$key])) {
$temp = $rlt['headers'][$key];