讨论数量:
打印出 源 kookie,发现使用第三方的 http 客户端会对 302 和 HttpOnly 做过滤,适配下 cookie 应该就行了
HTTP/1.1 302 Found
Location: /
Set-Cookie: gogs_awesome=wpjscc; Path=/; Max-Age=604800; HttpOnly
Set-Cookie: gogs_incredible=4405ba47f2a3d526a60d380d5ef0bb03f274345fdc990d3a9b7196f51655bb5529be; Path=/; Max-Age=604800; HttpOnly
Set-Cookie: _csrf=; Path=/; Max-Age=0
Set-Cookie: redirect_to=; Path=/; Max-Age=0
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Date: Mon, 30 Aug 2021 08:35:32 GMT
Content-Length: 0
@jcc123 这是大概的接收数据包逻辑
preg_match("/Content-Length:\s*\d*/i", $connection->data, $paramsLength);
$headerEnd = \strpos($connection->data, "\r\n\r\n");
$headerLength = strlen(substr($connection->data, 0, $headerEnd));
if (!empty($paramsLength)) {
$connection->totalContentLength = (int)str_replace("Content-Length: ", '', $paramsLength[0]);
echo "总的数据包长度:{ $connection->totalContentLength }";
$connection->receveContentLength += strlen($data);
echo "接收到的数据包长度: " . ($connection->receveContentLength - $headerLength - 4);
if ($connection->totalContentLength > $connection->receveContentLength) {
echo "\r\n数据包不完整,继续接受数据";
return;
}
}
$data = $connection->data;
preg_match("/Host:\s.*/i", serialize($connection->data), $match);
推荐文章: