所以我做了相当多的挖掘工作,似乎只能找到关于 SlimFramework 2 的信息,关于 3 的信息不多。
我的问题是这样的:
return $res->withStatus(401)->withHeader('Content-type','application/json')->write(json_encode(array(
'Error'=>'Your session has timed out.',
'X-SessionToken' => $session_uuid,
'Server date/time' => date('c'),
'Last activity' => Session::sharedInstance()->last_activity(),
'Path' => $path
)));
仍然返回 200 的状态,内容类型仍设置为 text/html,但我的所有身体都在那里。有什么想法吗?我尝试查看有关 write() 的 PSR-7 文档,以查看是否可能在此之后将标头和状态设置回默认值,但没有看到任何内容。