$errno
= "";
$errstr
= "";
$m_fp
=
fsockopen
(
$ghost
, 80,
$errno
,
$errstr
,10);
fwrite(
$m_fp
,
$sessionQuery
);
$lnum
= 0;
//获取详细应答头
$m_httphead
= Array();
$httpstas
=
explode
(" ",
fgets
(
$m_fp
,256));
$m_httphead
["http-edition"] = trim(
$httpstas
[0]);
$m_httphead
["http-state"] = trim(
$httpstas
[1]);
while
(!
feof
(
$m_fp
))
{
$line
= trim(
fgets
(
$m_fp
,256));
if
(
$line
== "" ||
$lnum
>100)
{
break
;
}
$hkey
= "";
$hvalue
= "";
$v
= 0;
for
(
$i
=0;
$i
<
strlen
(
$line
);
$i
++)
{
if
(
$v
==1)
{
$hvalue
.=
$line
[
$i
];
}
if
(
$line
[
$i
]==":")
{
$v
= 1;
}
if
(
$v
==0)
{
$hkey
.=
$line
[
$i
];
}
}
$hkey
= trim(
$hkey
);
if
(
$hkey
!="")
{
$m_httphead
[
strtolower
(
$hkey
)] = trim(
$hvalue
);
}
}