mirror of
https://github.com/kuaifan/dootask.git
synced 2026-09-08 21:19:25 +00:00
fix(http): Ihttp 响应头解析前初始化 headers 数组,消除未定义索引告警
This commit is contained in:
parent
13ba1d3bd7
commit
e4fbf9693a
@ -196,13 +196,14 @@ class Ihttp
|
|||||||
$rlt['status'] = $matches[3];
|
$rlt['status'] = $matches[3];
|
||||||
$rlt['responseline'] = $split2[0];
|
$rlt['responseline'] = $split2[0];
|
||||||
$header = explode("\r\n", $split2[1]);
|
$header = explode("\r\n", $split2[1]);
|
||||||
|
$rlt['headers'] = [];
|
||||||
$isgzip = false;
|
$isgzip = false;
|
||||||
$ischunk = false;
|
$ischunk = false;
|
||||||
foreach ($header as $v) {
|
foreach ($header as $v) {
|
||||||
$row = explode(':', $v);
|
$row = explode(':', $v);
|
||||||
$key = trim($row[0]);
|
$key = trim($row[0]);
|
||||||
$value = trim(substr($v, strlen($row[0]) + 1));
|
$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;
|
$rlt['headers'][$key][] = $value;
|
||||||
} elseif (!empty($rlt['headers'][$key])) {
|
} elseif (!empty($rlt['headers'][$key])) {
|
||||||
$temp = $rlt['headers'][$key];
|
$temp = $rlt['headers'][$key];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user